selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode
PATCH 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]
---
The original patch is for an identically named file and function in ltp and we need the same fix in kselftest. The patch is near identical with only a slight change to syscall instead of tst_syscall.
Is the way I have tagged this appropriate?
.../testing/selftests/futex/include/futex2test.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/testing/selftests/futex/include/futex2test.h +15 -0
@@ -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
Quoted 9 lines · Terry Tritton
Futex_waitvcan not acceptold_timespec32struct, so userspace should convert it from 32bit to 64bit before syscall in 32bit compatible mode.This fix is based off [1]
Signed-off-by Terry Tritton <[email protected]>Signed-off-by Wei Gao <[email protected]>
This Signed-off-by chain is broken. See
and the following chapters.
Thanks,
tglx