Skip to content

Commit

Permalink
futex_waitv: Convert 32bit timespec struct to 64bit for compatibility…
Browse files Browse the repository at this point in the history
… mode

futex_waitv() can not accept old_timespec32 struct, therefore userspace
should convert it from 32bit to 64bit before syscall in 32bit compatible
mode.

This fixes failure on futex_waitv01 on 32bit compatibility mode.

Detail info you can refer following email thread:
https://lore.kernel.org/lkml/[email protected]/

Link: https://lore.kernel.org/ltp/[email protected]/
Suggested-by: André Almeida <[email protected]>
Suggested-by: Thomas Gleixner <[email protected]>
Reviewed-by: Andrea Cervesato <andrea.cervesato.suse.com>
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Wei Gao <[email protected]>
  • Loading branch information
coolgw authored and pevik committed Feb 9, 2024
1 parent 64f7e56 commit ab803e8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions testcases/kernel/syscalls/futex/futex2test.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
#include <stdint.h>
#include "lapi/syscalls.h"
#include "futextest.h"
#include "lapi/abisize.h"

#ifdef TST_ABI32
struct timespec64 {
int64_t tv_sec;
int64_t tv_nsec;
};
#endif

/**
* futex_waitv - Wait at multiple futexes, wake on any
Expand All @@ -24,7 +32,16 @@ static inline int futex_waitv(volatile struct futex_waitv *waiters,
unsigned long nr_waiters, unsigned long flags,
struct timespec *timo, clockid_t clockid)
{
#ifdef TST_ABI32
struct timespec64 timo64 = {0};

timo64.tv_sec = timo->tv_sec;
timo64.tv_nsec = timo->tv_nsec;
return tst_syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &timo64, clockid);
#else
return tst_syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);

#endif
}

#endif /* _FUTEX2TEST_H */

0 comments on commit ab803e8

Please sign in to comment.