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

Michael Menasherov via ltp <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.