There are a couple of LTP testcases for this: kernel/syscalls/futex/futex_waitv0{1,2,3} Full documentation at: https://docs.kernel.org/userspace-api/futex2.html
Created attachment 184869 [details] proposed patch
(In reply to mcermak from comment #1) > Created attachment 184869 [details] > proposed patch +PRE(sys_futex_waitv) +{ + /* asmlinkage long sys_futex_waitv(struct futex_waitv __user *waiters, + * unsigned int nr_futexes, unsigned int flags, + * struct __kernel_timespec __user *timeout, clockid_t clockid); */ + + PRINT("sys_futex_waitv ( %#" FMT_REGWORD "x, %ld, %ld, %#" FMT_REGWORD "x, %d )", + ARG1, SARG2, SARG3, ARG4, ARG5); + PRE_MEM_READ("sys_futex_waitv(waiters)", ARG1, sizeof(struct vki_futex_waitv)); Shouldn't that be sizeof(struct vki_futex_waitv) * ARG2? + PRE_MEM_READ("sys_futex_waitv(timeout)", ARG4, sizeof(struct vki__kernel_timespec)); +} Looks good otherwise. Do all LTP futex_waitv tests pass with this?
(In reply to Mark Wielaard from comment #2) > (In reply to mcermak from comment #1) > > Created attachment 184869 [details] > > proposed patch > > +PRE(sys_futex_waitv) > +{ > + /* asmlinkage long sys_futex_waitv(struct futex_waitv __user *waiters, > + * unsigned int nr_futexes, unsigned > int flags, > + * struct __kernel_timespec __user > *timeout, clockid_t clockid); */ > + > + PRINT("sys_futex_waitv ( %#" FMT_REGWORD "x, %ld, %ld, %#" FMT_REGWORD > "x, %d )", > + ARG1, SARG2, SARG3, ARG4, ARG5); > + PRE_MEM_READ("sys_futex_waitv(waiters)", ARG1, sizeof(struct > vki_futex_waitv)); > > Shouldn't that be sizeof(struct vki_futex_waitv) * ARG2? https://docs.kernel.org/userspace-api/futex2.html reads: The pointer for the first item of the array is passed as waiters. So I assume the following structs are referenced one from another. > > + PRE_MEM_READ("sys_futex_waitv(timeout)", ARG4, sizeof(struct > vki__kernel_timespec)); > +} > > Looks good otherwise. Do all LTP futex_waitv tests pass with this? Yep, both regtest and ltp tests seem to test fine.
(In reply to mcermak from comment #3) > (In reply to Mark Wielaard from comment #2) > > (In reply to mcermak from comment #1) > > > Created attachment 184869 [details] > > > proposed patch > > > > +PRE(sys_futex_waitv) > > +{ > > + /* asmlinkage long sys_futex_waitv(struct futex_waitv __user *waiters, > > + * unsigned int nr_futexes, unsigned > > int flags, > > + * struct __kernel_timespec __user > > *timeout, clockid_t clockid); */ > > + > > + PRINT("sys_futex_waitv ( %#" FMT_REGWORD "x, %ld, %ld, %#" FMT_REGWORD > > "x, %d )", > > + ARG1, SARG2, SARG3, ARG4, ARG5); > > + PRE_MEM_READ("sys_futex_waitv(waiters)", ARG1, sizeof(struct > > vki_futex_waitv)); > > > > Shouldn't that be sizeof(struct vki_futex_waitv) * ARG2? > > https://docs.kernel.org/userspace-api/futex2.html reads: The pointer for the > first item of the array is passed as waiters. So I assume the following > structs are referenced one from another. Apologies, I mistakenly imagined a linked list. Will fix the patch!
Created attachment 184902 [details] updated patch
(In reply to mcermak from comment #5) > Created attachment 184902 [details] > updated patch LGTM
(In reply to Paul Floyd from comment #6) > (In reply to mcermak from comment #5) > > Created attachment 184902 [details] > > updated patch > > LGTM Agreed. Thanks for adding the SfMayBlock. Pushed as: commit 4b9d06bcde9935b3eae0307ec07fc1437a76e903 (HEAD -> master) Author: Martin Cermak <mcermak@redhat.com> Date: Fri Sep 12 07:52:55 2025 +0200 Wrap the futex_waitv syscall Wrap the futex2/futex_waitv syscall: sys_futex_waitv(struct futex_waitv __user *, waiters, unsigned int, nr_futexes, unsigned int, flags, struct __kernel_timespec __user *, timeout, clockid_t, clockid) sys_futex_waitv - Wait on a list of futexes @waiters: List of futexes to wait on @nr_futexes: Length of futexv @flags: Flag for timeout (monotonic/realtime) @timeout: Optional absolute timeout. @clockid: Clock to be used for the timeout, realtime or monotonic. Given an array of `struct futex_waitv`, wait on each uaddr. The thread wakes if a futex_wake() is performed at any uaddr. The syscall returns immediately if any waiter has *uaddr != val. *timeout is an optional timeout value for the operation. Each waiter has individual flags. The `flags` argument for the syscall should be used solely for specifying the timeout as realtime, if needed. Flags for private futexes, sizes, etc. should be used on the individual flags of each waiter. Returns the array index of one of the woken futexes. No further information is provided. Declare a futex_waitv wrapper in priv_syswrap-linux.h and hook it for {amd64,arm,arm64,mips64,ppc32,ppc64,riscv64,s390x\ ,x86}- linux using LINX_ with PRE handler in syswrap-linux.c https://bugs.kde.org/show_bug.cgi?id=506816