public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE
@ 2024-08-27 10:38 benjamin.grossschartner at urbanandmainlines dot com
2024-08-27 12:52 ` [Bug libc/32119] " sam at gentoo dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: benjamin.grossschartner at urbanandmainlines dot com @ 2024-08-27 10:38 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
Bug ID: 32119
Summary: struct stat has different size depending on
_POSIX_C_SOURCE
Product: glibc
Version: 2.39
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: benjamin.grossschartner at urbanandmainlines dot com
CC: drepper.fsp at gmail dot com
Target Milestone: ---
On 32bit architectures with 64bit time enabled, struct stat misses the
"__glibc_reserved" fields, if a POSIX version < 2008 is used.
As these reserved fields are also part of the struct used by the linux kernel,
it seems that this is a bug in the glibc headers.
The bug was introduced by:
4e8521333bea6e89fcef1020e59a5f799241c5d4
The last "#endif" in the file
"sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h" was missplaced.
In all other definitions of "struct stat" this "#ifdef __USE_XOPEN2K8" only
controls the handling of the time structs, but not these reserved fields.
Suggested fix:
diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
index 9ded57aa..124d0b59 100644
--- a/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
+++ b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
@@ -58,9 +58,8 @@
__fieldts64 (st_atime);
__fieldts64 (st_mtime);
__fieldts64 (st_ctime);
+# undef __fieldts64
+#endif
unsigned long int __glibc_reserved4;
unsigned long int __glibc_reserved5;
-
-# undef __fieldts64
-#endif
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
@ 2024-08-27 12:52 ` sam at gentoo dot org
2024-08-27 12:52 ` sam at gentoo dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sam at gentoo dot org @ 2024-08-27 12:52 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |codonell at redhat dot com,
| |lukma at denx dot de
--- Comment #1 from Sam James <sam at gentoo dot org> ---
commit 4e8521333bea6e89fcef1020e59a5f799241c5d4
Author: Lukasz Majewski <lukma@denx.de>
Date: Thu Oct 15 09:30:59 2020 +0200
y2038: Use a common definition for stat
Instead of replicate the same definitions from struct_stat_time64.h
on the multiple struct_stat.h, use a common header which is included
when required (struct_stat_time64_helper.h). The 64-bit time support
is added only for LFS support.
The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
2024-08-27 12:52 ` [Bug libc/32119] " sam at gentoo dot org
@ 2024-08-27 12:52 ` sam at gentoo dot org
2024-09-03 19:39 ` adhemerval.zanella at linaro dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sam at gentoo dot org @ 2024-08-27 12:52 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gentoo dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
2024-08-27 12:52 ` [Bug libc/32119] " sam at gentoo dot org
2024-08-27 12:52 ` sam at gentoo dot org
@ 2024-09-03 19:39 ` adhemerval.zanella at linaro dot org
2024-09-11 13:57 ` schwab@linux-m68k.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2024-09-03 19:39 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adhemerval.zanella at linaro dot o
| |rg
--- Comment #2 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
(In reply to Benjamin Grossschartner from comment #0)
> On 32bit architectures with 64bit time enabled, struct stat misses the
> "__glibc_reserved" fields, if a POSIX version < 2008 is used.
>
> As these reserved fields are also part of the struct used by the linux
> kernel, it seems that this is a bug in the glibc headers.
>
> The bug was introduced by:
> 4e8521333bea6e89fcef1020e59a5f799241c5d4
>
> The last "#endif" in the file
> "sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h" was missplaced.
> In all other definitions of "struct stat" this "#ifdef __USE_XOPEN2K8" only
> controls the handling of the time structs, but not these reserved fields.
>
>
> Suggested fix:
>
> diff --git a/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
> b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
> index 9ded57aa..124d0b59 100644
>
> --- a/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
>
> +++ b/sysdeps/unix/sysv/linux/bits/struct_stat_time64_helper.h
>
> @@ -58,9 +58,8 @@
>
> __fieldts64 (st_atime);
>
> __fieldts64 (st_mtime);
>
> __fieldts64 (st_ctime);
>
> +# undef __fieldts64
>
> +#endif
>
>
>
> unsigned long int __glibc_reserved4;
>
> unsigned long int __glibc_reserved5;
>
> -
>
> -# undef __fieldts64
>
> -#endif
I am not sure this is an issue, for the ABIs that would eventually use
'fstatat64_time64_stat' the __fstatat64_time64 (which would be called by
stat/lstat/fstat on both non-LFS and LFS mode) it would first try statx
(fstatat64_time64_statx) and then fallback to fstatat64
(fstatat64_time64_stat).
For both cases, the syscall will be issued with a temporary buffer and then
copies to the caller-provided buffer.
It is still an issue for TU built with different flags, but we already have
this issue for non-LFS and LFS; so I don't see an issue that __USE_XOPEN2K8
also generates incompatbile objects.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
` (2 preceding siblings ...)
2024-09-03 19:39 ` adhemerval.zanella at linaro dot org
@ 2024-09-11 13:57 ` schwab@linux-m68k.org
2024-09-11 17:06 ` fweimer at redhat dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2024-09-11 13:57 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
It is not ok to have a different layout and size depending on the value of
_POSIX_C_SOURCE. _FILE_OFFSET_BITS is an ABI-changing option, but selecting
the standard level is not.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
` (3 preceding siblings ...)
2024-09-11 13:57 ` schwab@linux-m68k.org
@ 2024-09-11 17:06 ` fweimer at redhat dot com
2024-09-12 19:50 ` adhemerval.zanella at linaro dot org
2024-09-13 11:30 ` carlos at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: fweimer at redhat dot com @ 2024-09-11 17:06 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
--- Comment #4 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to Andreas Schwab from comment #3)
> It is not ok to have a different layout and size depending on the value of
> _POSIX_C_SOURCE. _FILE_OFFSET_BITS is an ABI-changing option, but selecting
> the standard level is not.
Thanks, Andreas. I meant to write the same thing.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
` (4 preceding siblings ...)
2024-09-11 17:06 ` fweimer at redhat dot com
@ 2024-09-12 19:50 ` adhemerval.zanella at linaro dot org
2024-09-13 11:30 ` carlos at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2024-09-12 19:50 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
--- Comment #5 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
(In reply to Andreas Schwab from comment #3)
> It is not ok to have a different layout and size depending on the value of
> _POSIX_C_SOURCE. _FILE_OFFSET_BITS is an ABI-changing option, but selecting
> the standard level is not.
Right, but changing this would be technically an ABI break. I started to check
this issue and besides all old 32 abi, it seems that some newer 32 also have
similar problems due to how timespec is defined (the __timespec64 has padding,
where the 'struct stat' does not).
So it would require a lot of compact symbols, should we just paper over this
issue and fix it on all releases?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug libc/32119] struct stat has different size depending on _POSIX_C_SOURCE
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
` (5 preceding siblings ...)
2024-09-12 19:50 ` adhemerval.zanella at linaro dot org
@ 2024-09-13 11:30 ` carlos at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: carlos at redhat dot com @ 2024-09-13 11:30 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=32119
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |carlos at redhat dot com
--- Comment #6 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Adhemerval Zanella from comment #5)
> So it would require a lot of compact symbols, should we just paper over this
> issue and fix it on all releases?
That would be my inclination. I don't think these configurations are yet widely
deployed. We should ask Gentoo though.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-09-13 11:30 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 10:38 [Bug libc/32119] New: struct stat has different size depending on _POSIX_C_SOURCE benjamin.grossschartner at urbanandmainlines dot com
2024-08-27 12:52 ` [Bug libc/32119] " sam at gentoo dot org
2024-08-27 12:52 ` sam at gentoo dot org
2024-09-03 19:39 ` adhemerval.zanella at linaro dot org
2024-09-11 13:57 ` schwab@linux-m68k.org
2024-09-11 17:06 ` fweimer at redhat dot com
2024-09-12 19:50 ` adhemerval.zanella at linaro dot org
2024-09-13 11:30 ` carlos at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).