GNU bug report logs - #52410
"mv -T --backup=numbered hello world/" renameat2 infinite loop

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Vincent Vermilya <vincentvermilya@HIDDEN>; dated Fri, 10 Dec 2021 12:09:02 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Dec 2021 12:09:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 10 07:09:01 2021
Received: from localhost ([127.0.0.1]:45793 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mvehx-0007Io-2O
	for submit <at> debbugs.gnu.org; Fri, 10 Dec 2021 07:09:01 -0500
Received: from lists.gnu.org ([209.51.188.17]:38584)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincentvermilya@HIDDEN>) id 1mvd2i-0008In-94
 for submit <at> debbugs.gnu.org; Fri, 10 Dec 2021 05:22:20 -0500
Received: from eggs.gnu.org ([209.51.188.92]:52800)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vincentvermilya@HIDDEN>)
 id 1mvd2i-0003V2-1K
 for bug-coreutils@HIDDEN; Fri, 10 Dec 2021 05:22:20 -0500
Received: from [2607:f8b0:4864:20::933] (port=36480
 helo=mail-ua1-x933.google.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <vincentvermilya@HIDDEN>)
 id 1mvd2g-00037P-AY
 for bug-coreutils@HIDDEN; Fri, 10 Dec 2021 05:22:19 -0500
Received: by mail-ua1-x933.google.com with SMTP id r15so15936257uao.3
 for <bug-coreutils@HIDDEN>; Fri, 10 Dec 2021 02:22:17 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:from:date:message-id:subject:to;
 bh=qPWzLDdqQxJGoogYy3JKw2hZ/ldntYVdMupcK5pPVI4=;
 b=DpKcUNROdBb6Jo3XBiFI3IvBI7HRnJzdRiZqvy6a2Yd1/CgMHy+4PnMtOSNKHfG+i7
 6b0v9yyd6F2/RedQeXUxA+bgmAHL1RcNIxcy3PBcEpjo8uflqcV4Af+2klWE4SQCEhkj
 f9uqFyv67nnE8nFoC6XdMmRVkVFKxB88pR5clrcFghVa09a6ELpu2Qrz8wUjoWiDvnxR
 7KaV6c+lKkH4o6yFm5H6ilX5hbjkMWUZLN6u/gbcW/dh78/ZjPpa5Pdj5mBO8bdThEC5
 n6s0KwGB0qw5GSkYWjEWmGwmhVyfeOaHhy2tSIiZcLeY39cbYVUZWHwdpjRUw+WhHNtH
 5ScQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=qPWzLDdqQxJGoogYy3JKw2hZ/ldntYVdMupcK5pPVI4=;
 b=iG1nQynoVYzdWO4s0R7VSgzDFqN97uLnh9ykkXFnqJe5v/IWeOd4CGBdYFLmmKYhPu
 l5S9LM6R1lM/1Ceu3uFBiw8szTtfCxcZcN3X+IS/P93/QI+y0gH8R+gYC0AhSxfmiiy3
 +WpzZAlB38GoTasf5h/966FvhEhCRLO2tMFIcd33a/W8Nd0AkdW0Tz/qheeuojcfjJAF
 TWARW0YWhhix9qpxjSKaxGMljWUuipXdKb7a7AgvGcHZTfBuuITCOioX5riJ0rdZEz7E
 XjROxKl5GqZglNH8JbaRURzZKtswjFFNyAiLTHMHCZbEVt3i9sKZ7/oHzOlQmfAsaYKe
 SzMg==
X-Gm-Message-State: AOAM533vNrky37Y+0fa06QUeRXYq3Lk27ludG0aiAvWwV4WxJPrRKR8A
 JFyDfqslxEB7uOY8Gf7Roreze9wdPjblcH50+rMI1poiuTw=
X-Google-Smtp-Source: ABdhPJx6X+USwbnJvycs4y1FRw+AWgVin6nKQqmqb6xgt5+3V7I4SmwgzrLpLRHWAf8bVyKHvkzz1ZV0SlayAhlOzWc=
X-Received: by 2002:ab0:6ca7:: with SMTP id j7mr27471462uaa.133.1639131736647; 
 Fri, 10 Dec 2021 02:22:16 -0800 (PST)
MIME-Version: 1.0
From: Vincent Vermilya <vincentvermilya@HIDDEN>
Date: Fri, 10 Dec 2021 02:22:03 -0800
Message-ID: <CACGU48eHF=EV9+nhXVbMbijDw=j5HhwfKy6sUWA2ADUDzt4ozw@HIDDEN>
Subject: "mv -T --backup=numbered hello world/" renameat2 infinite loop
To: bug-coreutils@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000e72d8905d2c81843"
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::933
 (failed)
Received-SPF: pass client-ip=2607:f8b0:4864:20::933;
 envelope-from=vincentvermilya@HIDDEN; helo=mail-ua1-x933.google.com
X-Spam_score_int: 6
X-Spam_score: 0.6
X-Spam_bar: /
X-Spam_report: (0.6 / 5.0 requ) BAYES_20=-0.001, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 10 Dec 2021 07:08:59 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--000000000000e72d8905d2c81843
Content-Type: text/plain; charset="UTF-8"

If DEST directory has a trailing slash in "mv -T --backup=numbered", mv
gets stuck in an infinite loop. This does not happen without the trailing
slash. strace shows renameat2 as the call that gets looped on. This is
tested on coreutils 8.30 Ubuntu 20.04.

Example:
```
mkdir hello hello1 world/
mv -T --backup=numbered hello world/
strace mv -T --backup=numbered hello1 world/ 2>&1 | less
```
less output at infinite loop:
```
renameat2(AT_FDCWD, "world/", 3, "world.~1~", RENAME_NOREPLACE) = -1 EEXIST
(File exists)
lseek(3, 0, SEEK_SET)                   = 0
getdents64(3, /* 39 entries */, 32768)  = 1240
getdents64(3, /* 0 entries */, 32768)   = 0
renameat2(AT_FDCWD, "world/", 3, "world/", RENAME_NOREPLACE) = -1 EEXIST
(File exists)
lseek(3, 0, SEEK_SET)                   = 0
getdents64(3, /* 39 entries */, 32768)  = 1240
getdents64(3, /* 0 entries */, 32768)   = 0
renameat2(AT_FDCWD, "world/", 3, "world/", RENAME_NOREPLACE) = -1 EEXIST
(File exists)
lseek(3, 0, SEEK_SET)                   = 0
getdents64(3, /* 39 entries */, 32768)  = 1240
getdents64(3, /* 0 entries */, 32768)   = 0
```

--000000000000e72d8905d2c81843
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>If DEST directory has a trailing slash in &quot;mv -T=
 --backup=3Dnumbered&quot;, mv gets stuck in an infinite loop. This does no=
t happen without the trailing slash. strace shows renameat2 as the call tha=
t gets looped on. This is tested on coreutils 8.30 Ubuntu 20.04.<br><br></d=
iv>Example:<br>```<br>mkdir hello hello1 world/<br>mv -T --backup=3Dnumbere=
d hello world/<br>strace mv -T --backup=3Dnumbered hello1 world/ 2&gt;&amp;=
1 | less<br><div>```</div><div>less output at infinite loop:<br></div><div>=
```</div><div>renameat2(AT_FDCWD, &quot;world/&quot;, 3, &quot;world.~1~&qu=
ot;, RENAME_NOREPLACE) =3D -1 EEXIST (File exists)<br>lseek(3, 0, SEEK_SET)=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0<br>ge=
tdents64(3, /* 39 entries */, 32768) =C2=A0=3D 1240<br>getdents64(3, /* 0 e=
ntries */, 32768) =C2=A0 =3D 0<br>renameat2(AT_FDCWD, &quot;world/&quot;, 3=
, &quot;world/&quot;, RENAME_NOREPLACE) =3D -1 EEXIST (File exists)<br>lsee=
k(3, 0, SEEK_SET) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =3D 0<br>getdents64(3, /* 39 entries */, 32768) =C2=A0=3D 1240<br>ge=
tdents64(3, /* 0 entries */, 32768) =C2=A0 =3D 0<br>renameat2(AT_FDCWD, &qu=
ot;world/&quot;, 3, &quot;world/&quot;, RENAME_NOREPLACE) =3D -1 EEXIST (Fi=
le exists)<br>lseek(3, 0, SEEK_SET) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0<br>getdents64(3, /* 39 entries */, 32768) =
=C2=A0=3D 1240<br>getdents64(3, /* 0 entries */, 32768) =C2=A0 =3D 0</div>`=
``<br></div>

--000000000000e72d8905d2c81843--




Acknowledgement sent to Vincent Vermilya <vincentvermilya@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#52410; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 10 Dec 2021 12:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.