[LTP] [PATCH v17 0/2] futex: Add EFAULT error coverage tests
Michael Menasherov
mmenashe@redhat.com
Thu Jul 16 15:31:06 CEST 2026
Hi Petr,
Thanks for the review. Here is v17 addressing your feedback.
futex_wait06 and futex_wait07 were already merged. This series contains
the remaining two patches.
futex_cmp_requeue03:
Applied your nit — removed the exp_errno field from the testcase struct
and used EFAULT directly in TST_EXP_FAIL().
futex_wake05:
Applied both nits (list comment format, EFAULT directly). For the
kernel-space address case: you were right to question it. I couldn't
confirm consistent EFAULT across kernels, so I looked for a better
replacement.
I used AI assistance to research the kernel's get_user_pages() code
paths and cross-referenced existing LTP mmap tests to verify the
approach. The replacement I landed on is a shared file-backed mapping
where the file is truncated to 0 after mmap().
The three cases now exercise genuinely different code paths:
- unmapped memory fails at find_vma() (no VMA exists)
- PROT_NONE memory fails at get_user_pages_fast() (VMA exists but
page is inaccessible)
- the truncated file mapping triggers VM_FAULT_SIGBUS inside the page
fault handler (filemap_fault() sees offset beyond EOF), which
get_user_pages() propagates as EFAULT
The SIGBUS is never delivered to user space — get_user_pages() converts
VM_FAULT_SIGBUS to -EFAULT internally. This behavior has been stable
since before kernel 2.6 and works reliably on all architectures and
both 32/64-bit. The test uses .needs_tmpdir = 1.
Changes since v16:
- futex_wake05: replace kernel-space address case with truncated
file-backed mapping, fix comment to list format, use EFAULT directly
in TST_EXP_FAIL(), add .needs_tmpdir
- futex_cmp_requeue03: use EFAULT directly in TST_EXP_FAIL()
Michael Menasherov (2):
futex_wake05: Add EFAULT error coverage test
futex_cmp_requeue03: Add EFAULT error coverage test
runtest/syscalls | 2 +
testcases/kernel/syscalls/futex/.gitignore | 2 +
.../syscalls/futex/futex_cmp_requeue03.c | 103 ++++++++++++++++
.../kernel/syscalls/futex/futex_wake05.c | 113 ++++++++++++++++++
4 files changed, 220 insertions(+)
create mode 100644 testcases/kernel/syscalls/futex/futex_cmp_requeue03.c
create mode 100644 testcases/kernel/syscalls/futex/futex_wake05.c
--
2.55.0
More information about the ltp
mailing list