mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] y2038: uapi: use 64-bit __kernel_old_timespec::tv_nsec on x32
@ 2026-05-04  6:32 Thomas Weißschuh
  2026-07-07 22:00 ` [tip: timers/core] y2038: uapi: Use " tip-bot2 for Thomas Weißschuh
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2026-05-04  6:32 UTC (permalink / raw)
  To: Arnd Bergmann, Deepa Dinamani; +Cc: linux-kernel, Thomas Weißschuh

'struct __kernel_old_timespec' represents the 'native' time ABI of the
kernel. On 32-bit systems it uses 32-bit fields and on 64-bit systems
it uses 64-bit fields.
However the x86 x32 ABI uses the 64-bit time ABI natively.
This is correctly handled for the 'tv_sec' fields, through the typedefs
of '__kernel_old_time_t' -> '__kernel_long_t' -> 'long long'. The same
treatment was missed for 'tv_nsec'.

In practice this might not make much of a difference as the value of
'tv_nsec' will always fit into 32 bits and the missing bits fall
into the padding of the structure.
When introspecting the structure however, a difference can be observed.

Switch to 64-bit tv_nsec on x32.
No other architectures or ABIs are affected.

While this could be interpreted as violating the POSIX requirement of
'timespec::tv_nsec' being 'long',
* __kernel_old_timespec is not actually the POSIX timespec type,
* the requirement is gone in newer versions of POSIX,
* this matches glibc.

Fixes: 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Rebase on v7.1-rc1
- Extend commit message a bit
- Link to v1: https://lore.kernel.org/r/20260227-timespec-x32-v1-1-00b227168034@linutronix.de
---
Arnd, can you take this?

I'm not entirely sure if this warrants a stable backport.
---
 include/uapi/linux/time_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/time_types.h b/include/uapi/linux/time_types.h
index bcc0002115d3..03a0d8aaadca 100644
--- a/include/uapi/linux/time_types.h
+++ b/include/uapi/linux/time_types.h
@@ -30,7 +30,7 @@ struct __kernel_old_timeval {
 
 struct __kernel_old_timespec {
 	__kernel_old_time_t	tv_sec;		/* seconds */
-	long			tv_nsec;	/* nanoseconds */
+	__kernel_long_t		tv_nsec;	/* nanoseconds */
 };
 
 struct __kernel_old_itimerval {

---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260224-timespec-x32-0f9c15531320

Best regards,
--  
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip: timers/core] y2038: uapi: Use 64-bit __kernel_old_timespec::tv_nsec on x32
  2026-05-04  6:32 [PATCH v2] y2038: uapi: use 64-bit __kernel_old_timespec::tv_nsec on x32 Thomas Weißschuh
@ 2026-07-07 22:00 ` tip-bot2 for Thomas Weißschuh
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Thomas Weißschuh @ 2026-07-07 22:00 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: thomas.weissschuh, Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     79ced850e549e8c86b772a79ea417a1425b5c04b
Gitweb:        https://git.kernel.org/tip/79ced850e549e8c86b772a79ea417a1425b5c04b
Author:        Thomas Weißschuh <thomas.weissschuh@linutronix.de>
AuthorDate:    Mon, 04 May 2026 08:32:26 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 07 Jul 2026 23:59:24 +02:00

y2038: uapi: Use 64-bit __kernel_old_timespec::tv_nsec on x32

'struct __kernel_old_timespec' represents the 'native' time ABI of the
kernel. On 32-bit systems it uses 32-bit fields and on 64-bit systems
it uses 64-bit fields.

However the x86 x32 ABI uses the 64-bit time ABI natively.  This is
correctly handled for the 'tv_sec' fields, through the typedefs of
'__kernel_old_time_t' -> '__kernel_long_t' -> 'long long'. The same
treatment was missed for 'tv_nsec'.

In practice this might not make much of a difference as the value of
'tv_nsec' will always fit into 32 bits and the missing bits fall
into the padding of the structure.

When introspecting the structure however, a difference can be observed.

Switch to 64-bit tv_nsec on x32.  No other architectures or ABIs are
affected.

While this could be interpreted as violating the POSIX requirement of
'timespec::tv_nsec' being 'long':

  * __kernel_old_timespec is not actually the POSIX timespec type

  * the requirement is gone in newer versions of POSIX

  * this matches glibc

Fixes: 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260504-timespec-x32-v2-1-0739c9047fc4@linutronix.de
---
 include/uapi/linux/time_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/time_types.h b/include/uapi/linux/time_types.h
index bcc0002..03a0d8a 100644
--- a/include/uapi/linux/time_types.h
+++ b/include/uapi/linux/time_types.h
@@ -30,7 +30,7 @@ struct __kernel_old_timeval {
 
 struct __kernel_old_timespec {
 	__kernel_old_time_t	tv_sec;		/* seconds */
-	long			tv_nsec;	/* nanoseconds */
+	__kernel_long_t		tv_nsec;	/* nanoseconds */
 };
 
 struct __kernel_old_itimerval {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-07 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-04  6:32 [PATCH v2] y2038: uapi: use 64-bit __kernel_old_timespec::tv_nsec on x32 Thomas Weißschuh
2026-07-07 22:00 ` [tip: timers/core] y2038: uapi: Use " tip-bot2 for Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®