Skip to contentSkip to conversation

selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode

PATCH Superseded Terry Tritton 3 participants 6 messages Jul 1, 2025 – Jul 2, 2025

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode

Futex_waitv can not accept old_timespec32 struct, so userspace should convert it from 32bit to 64bit before syscall in 32bit compatible mode.

This fix is based off [1]

---
 .../testing/selftests/futex/include/futex2test.h  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/testing/selftests/futex/include/futex2test.h +15 -0
index ea79662405bc..6780e51eb2d6 100644
@@ -55,6 +55,13 @@ struct futex32_numa {
 	futex_t numa;
 };
 
+#if !defined(__LP64__)
+struct timespec64 {
+	int64_t tv_sec;
+	int64_t tv_nsec;
+};
+#endif
+
 /**
  * futex_waitv - Wait at multiple futexes, wake on any
  * @waiters:    Array of waiters
@@ -65,7 +72,15 @@ struct futex32_numa {
 static inline int futex_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters,
 			      unsigned long flags, struct timespec *timo, clockid_t clockid)
 {
+#if !defined(__LP64__)
+	struct timespec64 timo64 = {0};
+
+	timo64.tv_sec = timo->tv_sec;
+	timo64.tv_nsec = timo->tv_nsec;
+	return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &timo64, clockid);
+#else
 	return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);
+#endif
 }
 
 /*
Signature · 1 line
2.39.5
#1 lore raw

Sorry forgot to save the change log before sending.
v2: fix Signed-off-by chain

Quoted 51 lines · Terry Tritton

Futex_waitv can not accept old_timespec32 struct, so userspace should convert it from 32bit to 64bit before syscall in 32bit compatible mode.

This fix is based off [1]

---
 .../testing/selftests/futex/include/futex2test.h  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/testing/selftests/futex/include/futex2test.h +15 -1
index ea79662405bc..6780e51eb2d6 100644
@@ -55,6 +55,13 @@ struct futex32_numa {
        futex_t numa;
 };
 
+#if !defined(__LP64__)
+struct timespec64 {
+       int64_t tv_sec;
+       int64_t tv_nsec;
+};
+#endif
+
 /**
  * futex_waitv - Wait at multiple futexes, wake on any
  * @waiters:    Array of waiters
@@ -65,7 +72,15 @@ struct futex32_numa {
 static inline int futex_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters,
                              unsigned long flags, struct timespec *timo, clockid_t clockid)
 {
+#if !defined(__LP64__)
+       struct timespec64 timo64 = {0};
+
+       timo64.tv_sec = timo->tv_sec;
+       timo64.tv_nsec = timo->tv_nsec;
+       return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &timo64, clockid);
+#else
        return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);
+#endif
 }
 
 /*
--

2.39.5

#2 lore raw
In reply to Terry Tritton
Quoted 9 lines · Terry Tritton

Futex_waitv can not accept old_timespec32 struct, so userspace should convert it from 32bit to 64bit before syscall in 32bit compatible mode.

This fix is based off [1]

This is still wrong.

If it is based on someone else work, then you need to attribute it Originally-by and omit the Signed-off-by of the original author.

If you just picked it up and adopted it to a later kernel version then you need to add 'From: Original Author' and preserve his Signed-off-by.

If you collaborated with him, then you want to use Co-developed-by.

All of this is documented in Documentation/process/

#3 lore raw
Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · Terry Tritton

Futex_waitv can not accept old_timespec32 struct, so userspace should convert it from 32bit to 64bit before syscall in 32bit compatible mode.

This fix is based off [1]

Quoted 7 lines

This is still wrong.

If it is based on someone else work, then you need to attribute it Originally-by and omit the Signed-off-by of the original author.

If you just picked it up and adopted it to a later kernel version then you need to add 'From: Original Author' and preserve his Signed-off-by.

@Terry @Thomas, Thank you both for the mention in the commit. I appreciate being included. I guess above options both good.

Quoted 5 lines

If you collaborated with him, then you want to use Co-developed-by.

All of this is documented in Documentation/process/

#4 lore raw
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

This is still wrong.

Quoted 8 lines
Quoted 5 lines

If it is based on someone else work, then you need to attribute it Originally-by and omit the Signed-off-by of the original author.

If you just picked it up and adopted it to a later kernel version then you need to add 'From: Original Author' and preserve his Signed-off-by.

@Terry @Thomas, Thank you both for the mention in the commit. I appreciate being included. I guess above options both good.

No problem!
Not sure how often this situation comes up where an ltp patch is also needed in kselftest.

#5 lore raw
In reply to Thomas Gleixner
Quoted 8 lines
Quoted 2 lines

This is still wrong.

If it is based on someone else work, then you need to attribute it Originally-by and omit the Signed-off-by of the original author.

Quoted 7 lines

If you just picked it up and adopted it to a later kernel version then you need to add 'From: Original Author' and preserve his Signed-off-by.

If you collaborated with him, then you want to use Co-developed-by.

All of this is documented in Documentation/process/

Ah sorry, I thought it was just the order that was wrong.

Thanks for pointing me in the right direction!