From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#20597: =?UTF-8?Q?=E2=80=98unlinkat=E2=80=99?= bug in Linux 4.0.2 leads to tar test failure Date: Sun, 24 May 2015 15:53:07 +0200 Message-ID: <874mn26q0s.fsf__9069.10102717138$1432475660$gmane$org@gnu.org> References: <55584206.8020101@uwaterloo.ca> <871tich8ui.fsf@gnu.org> <5561771F.2010203@uwaterloo.ca> <87617i9plu.fsf_-_@gnu.org> <5561BCC4.6040604@draigBrady.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwWLr-0005tq-Gf for bug-guix@gnu.org; Sun, 24 May 2015 09:54:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YwWLq-0007eC-Fd for bug-guix@gnu.org; Sun, 24 May 2015 09:54:03 -0400 Received: from debbugs.gnu.org ([140.186.70.43]:44386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwWLq-0007e8-C5 for bug-guix@gnu.org; Sun, 24 May 2015 09:54:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YwWLq-0000oy-3b for bug-guix@gnu.org; Sun, 24 May 2015 09:54:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <5561BCC4.6040604@draigBrady.com> ("=?UTF-8?Q?P=C3=A1draig?= Brady"'s message of "Sun, 24 May 2015 12:57:56 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: bug-gnulib@gnu.org, 20597@debbugs.gnu.org P=C3=A1draig Brady skribis: > On 24/05/15 12:33, Ludovic Court=C3=A8s wrote: [...] >> unlinkat(4, "foo_file", 0) =3D 0 >> unlinkat(AT_FDCWD, "foo", AT_REMOVEDIR) =3D 0 >> unlinkat(5, "bar_file", 0) =3D 0 >> unlinkat(4, "../bar", AT_REMOVEDIR) =3D -1 ENOENT (No such file or d= irectory) >> --8<---------------cut here---------------end--------------->8--- >>=20 >> Contrast this with the same thing on 4.0.4-gnu: >>=20 >> --8<---------------cut here---------------start------------->8--- >> unlinkat(4, "foo_file", 0) =3D 0 >> unlinkat(AT_FDCWD, "foo", AT_REMOVEDIR) =3D 0 >> unlinkat(5, "bar_file", 0) =3D 0 >> unlinkat(4, "../bar", AT_REMOVEDIR) =3D 0 >> --8<---------------cut here---------------end--------------->8--- >>=20 >> So this looks like a 4.0.2 kernel bug that Gnulib=E2=80=99s unlinkat sho= uld >> perhaps work around. >>=20 >> Thoughts? > > Maybe. How widely deployed was 4.0.2 (It's not used in Red Hat land for e= xample). > How many versions was the bug present for? I don=E2=80=99t know, and I haven=E2=80=99t been able to find traces of a f= ix in that area in the kernel. OTOH, after rereading the analysis at , it may be that the 4.0.2 behavior is POSIX-conforming, in which case we=E2=80= =99d rather fix tar (or its tests) instead: The BSD behavior appears to be in line with POSIX. unlinkat() with AT_REMOVEDIR is equivalent to rmdir(), whose specification says: If one or more processes have the directory open when the last link is removed, the dot and dot-dot entries, if present, shall be removed before rmdir() returns and no new entries may be created in the directory, but the directory shall not be removed until all references to the directory are closed. Without "..", the path resolution of the subsequent unlinkat() call should--or at least can--fail. WDYT? Thanks, Ludo=E2=80=99.