[PATCH v5 0/4] selftests/mm: refactor pkey helpers and fix mmap error handling

Hongfu Li posted 4 patches 6 days, 23 hours ago
There is a newer version of this series
tools/testing/selftests/mm/pkey-helpers.h     |  4 +-
tools/testing/selftests/mm/pkey-powerpc.h     |  2 +-
.../selftests/mm/pkey_sighandler_tests.c      | 69 +++++++-------
tools/testing/selftests/mm/pkey_util.c        | 86 +++++++++++++++++
tools/testing/selftests/mm/protection_keys.c  | 95 ++-----------------
5 files changed, 131 insertions(+), 125 deletions(-)
[PATCH v5 0/4] selftests/mm: refactor pkey helpers and fix mmap error handling
Posted by Hongfu Li 6 days, 23 hours ago
The main changes in this series are to refactor shared tracing and assertion
helpers into a common file, unify both pkey selftests on pkey_assert() and 
per-test tracing for consistent diagnostics, and add missing mmap() return 
checks with MAP_FAILED used throughout for readability and consistency.

Hongfu Li (4):
  selftests/mm: move pkey selftest helpers to pkey_util.c
  selftests/mm: unify pkey sighandler selftest assertions and tracing
  selftests/mm: use pkey_assert on clone_raw failure in pkey test
  selftests/mm: add missing mmap() return checks in pkey tests

 tools/testing/selftests/mm/pkey-helpers.h     |  4 +-
 tools/testing/selftests/mm/pkey-powerpc.h     |  2 +-
 .../selftests/mm/pkey_sighandler_tests.c      | 69 +++++++-------
 tools/testing/selftests/mm/pkey_util.c        | 86 +++++++++++++++++
 tools/testing/selftests/mm/protection_keys.c  | 95 ++-----------------
 5 files changed, 131 insertions(+), 125 deletions(-)

---
v5:
- Use ret instead of child_pid to hold the return value of clone_raw().
- Make tracing_on(), tracing_off() non-static.
  Remove cat_into_file() declaration from pkey-helpers.h.
v4:
- Base changes on top of the latest mm-unstable branch.
- Split the first patch into three:
  patch 1: move pkey selftest helpers to shared code;
  patch 2: unify sighandler selftest assertions and per-test tracing;
  patch 3: use pkey_assert() on clone_raw() failure.
- Use ksft_exit_fail_perror() in main() for mmap() failure.
v3:
- Use pkey_assert() for remaining sigaction() and clone_raw() error
  checks for consistency.
v2:
- Update commit message
- Move shared tracing and assertion helpers to a common file,
  replace assert() with pkey_assert() in sighandler tests
- Drop assert() from main() in protection_keys.c and add a proper error
  message instead.
- Link to v1: https://lore.kernel.org/all/20260518082120.3890552-1-lihongfu@kylinos.cn/
-- 
2.50.1
Re: [PATCH v5 0/4] selftests/mm: refactor pkey helpers and fix mmap error handling
Posted by Andrew Morton 6 days, 6 hours ago
On Mon,  1 Jun 2026 14:19:49 +0800 Hongfu Li <lihongfu@kylinos.cn> wrote:

> The main changes in this series are to refactor shared tracing and assertion
> helpers into a common file, unify both pkey selftests on pkey_assert() and 
> per-test tracing for consistent diagnostics, and add missing mmap() return 
> checks with MAP_FAILED used throughout for readability and consistency.

Thanks.  AI review found a couple of legitimate-looking issues.  At
least one of these was also reported against the v2(?) series and you
said you'd take a look.  Were these things false positives?

	https://sashiko.dev/#/patchset/20260601061953.696844-1-lihongfu@kylinos.cn
Re: [PATCH v5 0/4] selftests/mm: refactor pkey helpers and fix mmap error handling
Posted by Hongfu Li 6 days ago
> > The main changes in this series are to refactor shared tracing and assertion
> > helpers into a common file, unify both pkey selftests on pkey_assert() and 
> > per-test tracing for consistent diagnostics, and add missing mmap() return 
> > checks with MAP_FAILED used throughout for readability and consistency.
> 
> Thanks.  AI review found a couple of legitimate-looking issues.  At
> least one of these was also reported against the v2(?) series and you
> said you'd take a look.  Were these things false positives?
> 
> 	https://sashiko.dev/#/patchset/20260601061953.696844-1-lihongfu@kylinos.cn

Thanks for pointing these out.
I initially suspected this one was a false positive, but upon recheck, 
it also needs a fix. I will address both issues in the next revision.

Best regards,
Hongfu