GNU bug report logs - #72770
stat: filesystem ID regression in 9.5 with musl libc

Previous Next

Package: coreutils;

Reported by: Natanael Copa <ncopa <at> alpinelinux.org>

Date: Fri, 23 Aug 2024 07:16:02 UTC

Severity: normal

To reply to this bug, email your comments to 72770 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#72770; Package coreutils. (Fri, 23 Aug 2024 07:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Natanael Copa <ncopa <at> alpinelinux.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 23 Aug 2024 07:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Natanael Copa <ncopa <at> alpinelinux.org>
To: bug-coreutils <at> gnu.org
Subject: stat: filesystem ID regression in 9.5 with musl libc
Date: Fri, 23 Aug 2024 09:14:34 +0200
With coreutils 9.5 stat -f -c %i returns wrong value with musl libc.

$ docker run --rm -it -v /tmp:/tmp alpine:3.20 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
stat (GNU coreutils) 9.5
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Michael Meskes.
4dc59e8900000000
4dc59e89680d9b7c

Coreutils returns 4dc59e8900000000 instead of the expected 4dc59e89680d9b7c.

With 9.4 this works as expected:

$ docker run --rm -it -v /tmp:/tmp alpine:3.19 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
stat (GNU coreutils) 9.4
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Michael Meskes.
4dc59e89680d9b7c
4dc59e89680d9b7c

Downstream report: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16386




Information forwarded to bug-coreutils <at> gnu.org:
bug#72770; Package coreutils. (Fri, 23 Aug 2024 10:44:01 GMT) Full text and rfc822 format available.

Message #8 received at 72770 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Natanael Copa <ncopa <at> alpinelinux.org>, 72770 <at> debbugs.gnu.org
Subject: Re: bug#72770: stat: filesystem ID regression in 9.5 with musl libc
Date: Fri, 23 Aug 2024 11:41:28 +0100
On 23/08/2024 08:14, Natanael Copa wrote:
> With coreutils 9.5 stat -f -c %i returns wrong value with musl libc.
> 
> $ docker run --rm -it -v /tmp:/tmp alpine:3.20 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
> stat (GNU coreutils) 9.5
> Copyright (C) 2024 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
> Written by Michael Meskes.
> 4dc59e8900000000
> 4dc59e89680d9b7c
> 
> Coreutils returns 4dc59e8900000000 instead of the expected 4dc59e89680d9b7c.
> 
> With 9.4 this works as expected:
> 
> $ docker run --rm -it -v /tmp:/tmp alpine:3.19 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
> stat (GNU coreutils) 9.4
> Copyright (C) 2023 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
> Written by Michael Meskes.
> 4dc59e89680d9b7c
> 4dc59e89680d9b7c
> 
> Downstream report: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16386

I can't see what might have changed on the coreutils side with a quick look.
It would help eliminate cases if you provided strace output from 9.4 and 9.5

thanks,
Pádraig




Information forwarded to bug-coreutils <at> gnu.org:
bug#72770; Package coreutils. (Fri, 23 Aug 2024 11:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 72770 <at> debbugs.gnu.org (full text, mbox):

From: Natanael Copa <ncopa <at> alpinelinux.org>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 72770 <at> debbugs.gnu.org
Subject: Re: bug#72770: stat: filesystem ID regression in 9.5 with musl libc
Date: Fri, 23 Aug 2024 13:39:58 +0200
On Fri, 23 Aug 2024 11:41:28 +0100
Pádraig Brady <P <at> draigBrady.com> wrote:

> On 23/08/2024 08:14, Natanael Copa wrote:
> > With coreutils 9.5 stat -f -c %i returns wrong value with musl libc.
> > 
> > $ docker run --rm -it -v /tmp:/tmp alpine:3.20 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
> > stat (GNU coreutils) 9.5
> > Copyright (C) 2024 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.
> > 
> > Written by Michael Meskes.
> > 4dc59e8900000000
> > 4dc59e89680d9b7c
> > 
> > Coreutils returns 4dc59e8900000000 instead of the expected 4dc59e89680d9b7c.
> > 
> > With 9.4 this works as expected:
> > 
> > $ docker run --rm -it -v /tmp:/tmp alpine:3.19 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
> > stat (GNU coreutils) 9.4
> > Copyright (C) 2023 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.
> > 
> > Written by Michael Meskes.
> > 4dc59e89680d9b7c
> > 4dc59e89680d9b7c
> > 
> > Downstream report: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16386  
> 
> I can't see what might have changed on the coreutils side with a quick look.
> It would help eliminate cases if you provided strace output from 9.4 and 9.5

I think the difference is that with 9.4 it ends up using statfs(2), and
with 9.5 it ends up using statvfs(3).

musl only uses 32 bits of the returned 64 bits from statfs(2) to match the POSIX interface.

https://git.musl-libc.org/cgit/musl/tree/src/stat/statvfs.c?id=dd1e63c3638d5f9afb857fccf6ce1415ca5f1b8b#n39

I believe they do so to have consistent fsid on 32 bit and 64 bit architectures.

> 
> thanks,
> Pádraig





Information forwarded to bug-coreutils <at> gnu.org:
bug#72770; Package coreutils. (Fri, 23 Aug 2024 17:36:01 GMT) Full text and rfc822 format available.

Message #14 received at 72770 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Natanael Copa <ncopa <at> alpinelinux.org>
Cc: 72770 <at> debbugs.gnu.org
Subject: Re: bug#72770: stat: filesystem ID regression in 9.5 with musl libc
Date: Fri, 23 Aug 2024 18:33:04 +0100
On 23/08/2024 12:39, Natanael Copa wrote:
> On Fri, 23 Aug 2024 11:41:28 +0100
> Pádraig Brady <P <at> draigBrady.com> wrote:
> 
>> On 23/08/2024 08:14, Natanael Copa wrote:
>>> With coreutils 9.5 stat -f -c %i returns wrong value with musl libc.
>>>
>>> $ docker run --rm -it -v /tmp:/tmp alpine:3.20 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
>>> stat (GNU coreutils) 9.5
>>> Copyright (C) 2024 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.
>>>
>>> Written by Michael Meskes.
>>> 4dc59e8900000000
>>> 4dc59e89680d9b7c
>>>
>>> Coreutils returns 4dc59e8900000000 instead of the expected 4dc59e89680d9b7c.
>>>
>>> With 9.4 this works as expected:
>>>
>>> $ docker run --rm -it -v /tmp:/tmp alpine:3.19 sh -c "apk add --quiet coreutils && stat --version && stat -f -c %i /tmp && busybox stat -f -c %i /tmp"
>>> stat (GNU coreutils) 9.4
>>> Copyright (C) 2023 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.
>>>
>>> Written by Michael Meskes.
>>> 4dc59e89680d9b7c
>>> 4dc59e89680d9b7c
>>>
>>> Downstream report: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16386
>>
>> I can't see what might have changed on the coreutils side with a quick look.
>> It would help eliminate cases if you provided strace output from 9.4 and 9.5
> 
> I think the difference is that with 9.4 it ends up using statfs(2), and
> with 9.5 it ends up using statvfs(3).
> 
> musl only uses 32 bits of the returned 64 bits from statfs(2) to match the POSIX interface.
> 
> https://git.musl-libc.org/cgit/musl/tree/src/stat/statvfs.c?id=dd1e63c3638d5f9afb857fccf6ce1415ca5f1b8b#n39
> 
> I believe they do so to have consistent fsid on 32 bit and 64 bit architectures.

Interesting. I see musl has been doing this truncation since 2011,
but I guess the coreutils build picked up statvfs() since musl
started returning f_type in it:
https://git.musl-libc.org/cgit/musl/commit/src/stat/statvfs.c?id=7291c6c6
I suppose we could adjust m4/stat-prog.m4 in coreutils to
avoid statvfs detection on musl

It would be worth suggesting to the musl folks to avoid this truncation.

thanks,
Pádraig





This bug report was last modified 295 days ago.

Previous Next


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