From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13997 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Markus Wichmann Newsgroups: gmane.linux.lib.musl.general Subject: Re: futimens on musl libc (fwd) Date: Sun, 24 Mar 2019 19:42:55 +0100 Message-ID: <20190324184255.GA18043@voyager> References: <20190324142118.GS23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248921"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-14013-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 24 19:43:17 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1h885V-0012fU-Ow for gllmg-musl@m.gmane.org; Sun, 24 Mar 2019 19:43:17 +0100 Original-Received: (qmail 30217 invoked by uid 550); 24 Mar 2019 18:43:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30193 invoked from network); 24 Mar 2019 18:43:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1553452983; bh=j8y5M0vZeWGZVv5sf9AAfb+HgSeGgIqCwDyZeTsKyCU=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=ADpDJgoLMzGsvftwJwQWHCkQcHz4D35XVIF9ThCwAz53DkpUQvDRlQNnnboocEWBe dEzNP4qY4QI71QBC4rnuZXAjI4Ivr1UwFa8XJOwomThZUb7ajF8MuLkNQSt8BJ4e80 8jUbPJvwwTLNyZUzxAu23QykHPGT6VfYZfxGQ6j8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Content-Disposition: inline In-Reply-To: <20190324142118.GS23599@brightrain.aerifal.cx> X-Provags-ID: V03:K1:2h+xyyOAC5AAkXuyJNuD8MvduoEc+UvdziYOA2rz6M1WELTwjuc Vl9m0dq9AvCSu9OUZSvwR5XoAE2zNib0X5/9CbODJllRGafDJySZ0+25I+S/vDg+ZmNjKCU XSiO1cLwTfx2e80HSUZJP73j82uzssXRd5ioCgw5plmHfMXlbELfATwsf/UUNKlfXclQA+x 6q0gLulbwQbEBbvdIC46w== X-UI-Out-Filterresults: notjunk:1;V03:K0:wclYD1UhIq0=:ucv61NZUgK7BLALeJyaHwd HhAmiWk8YoZ/XRI6VSAwc5v5sgHa/SaLH3+9HJ1EjncS/SUdR7S06nqTPAyNYpt2emcH8Lx2Z cXAFV2wo4qYCb7YT7zadZi6qQGgRm/eVTgyFhMBQquUYxtqOynfnETfmLC96j0Ucg9dH6etKH HkruM5cZzp7E6bFw6JKoYwIuJK+SHsNejpecGSBNHZyyNgIgzHMM0/hpi7I6AfJbQSTTz4Ege bxbOPiQIYEWuk324zVgTLHrNlmvzuRahyTw31IV0Yc0Sp1TZcjhWR29YfvOftEdZQAjprvwwI 7QOpO5jLLE5mi2q74twatyeZAOlxqcfwweXVEbORVBp5ZnSQhaQ+A/ShALnnx48uJvpgYjCK5 cGWp7TGfCQqPkNo3GU4hgDUs9AMD7ukKa2VXdHpr1rUWQ1mYwjQuKL3M6yGInOPXBkL10tX0t 0dbacSFc91m5YMAWN1XaeeJpwk05nBbdrCmRlJRDSegP8tjNs4136RI1SHhSl+HmsN0o1u2pl F/mPAhkYMmT2dc4qOMPSSLmFYXRF4U0s0AzAjbD4DoDzMHb5d5DZws+1REtncDlc0NGIwQiCp ZLVrP1KI+qeIscI1EC/pOhUjIw81ntdRc9UD5amF6n2lB/FyLu3l1Ch6DZ3VE9ItSj9myIZ4o n/PXHB0/18SjU5BbgZrFfQiMr1DHNMA5TQxrHo1k38PySECsTIrneOSdYlvtVg8KqUMXWEzAp Kxez5TfGnHne06vWb/2Q1z5r9SnG5xknnbjv+gLs6pLSc3gpma6aJFo1y+NBVXGgqPSuBy2+ Xref: news.gmane.org gmane.linux.lib.musl.general:13997 Archived-At: On Sun, Mar 24, 2019 at 10:21:18AM -0400, Rich Felker wrote: > I think this needs action but I'm not clear what the exact mechanism > is yet, so I'm forwarding to the list. > > ----- Forwarded message from Bruno Haible ----- > > From: Bruno Haible > To: bug-gnulib@gnu.org, Rich Felker > Subject: futimens on musl libc > Date: Sat, 23 Mar 2019 21:40:33 +0100 > Message-ID: <4061903.SY8uJAIc8I@omega> > > The gnulib configure test in m4/futimens.m4, when run on Alpine Linux 3.= 7, > determines that the errno value is not as expected for a wrong fd. > > Let me document this in gnulib and update the cross-compilation guess > accordingly. > > Rich, FYI: The test program is this one: > > #include > #include > #include > #include > #include > int main () > { > struct timespec ts[2]; > int fd =3D creat ("conftest.file", 0600); > struct stat st; > if (fd < 0) return 1; > ts[0].tv_sec =3D 1; > ts[0].tv_nsec =3D UTIME_OMIT; > ts[1].tv_sec =3D 1; > ts[1].tv_nsec =3D UTIME_NOW; > errno =3D 0; > if (futimens (AT_FDCWD, NULL) =3D=3D 0) return 2; > if (errno !=3D EBADF) return 3; /* <=3D=3D It fails here */ Ah! There are multiple errors present in the call, but gnulib expects a certain one of these to be returned. futimens() should return EBADF for invalid FD, and EFAULT for invalid buffer address (second argument, according to manpage). However, musl implements futimens in terms of utimensat(), which just wraps a syscall of the same name on recent kernels (i.e. there's an optional fallback there that won't be used if the error from the first try isn't ENOSYS). According to the manpage, utimensat() returns EFAULT for invalid buffer address, and if the fd happens to be AT_FDCWD, but the path name is NULL (which it is when the call comes in from futimens()). POSIX is also rather clear on the matter: |The futimens() function shall fail if: | |[EBADF] | The fd argument is not a valid file descriptor. If the test program were patched to provide a propper buffer to futimens(), musl's implementation would still return EFAULT instead of the required EBADF. We might have to test for AT_FDCWD in futimens(), before passing it on to utimensat(). Are there other special FDs we have to consider? Ciao, Markus