Skip to content

futex: Add EFAULT error coverage tests

Michael Menasherov via ltp ltp 17 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v17 Latest2 patches 2 repliesIn review
  2. v162 patches 5 repliesSuperseded
  3. v152 patches 4 repliesSuperseded
Earlier versions · 14
VersionPostedPatchesRepliesStatus
v144 patches8 repliesSuperseded
v134 patches1 replySuperseded
v124 patches1 replySuperseded
v114 patches1 replySuperseded
v104 patches1 replySuperseded
v94 patches1 replySuperseded
v84 patches1 replySuperseded
v74 patches1 replySuperseded
v64 patches2 repliesSuperseded
v54 patches1 replySuperseded
v44 patches9 repliesSuperseded
v31 patch1 replySuperseded
v21 patch2 repliesSuperseded
v11 patch1 replySuperseded

Changes in v17 from the cover letter

- 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()

Patches in v17 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2futex_wake05: Add EFAULT error coverage testruntest/syscalls testcases/kernel/syscalls/futex/.gitignore testcases/kernel/syscalls/futex/futex_wake05.c+115 -02 replies
2/2futex_cmp_requeue03: Add EFAULT error coverage testruntest/syscalls testcases/kernel/syscalls/futex/.gitignore testcases/kernel/syscalls/futex/futex_cmp_requeue03.c+105 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v17 yet.

Read the v17 thread

Cover letter [LTP] [PATCH v17 0/2] futex: Add EFAULT error coverage tests

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
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp