Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH 0/2] selftests/yama: add ptrace_scope and PR_SET_PTRACER tests
@ 2026-11-25 12:59 Guicai Ma
  2026-11-25 12:59 ` [PATCH 1/2] selftests/yama: add ptrace_scope selftests Guicai Ma
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guicai Ma @ 2026-11-25 12:59 UTC (permalink / raw)
  To: Kees Cook, Shuah Khan, linux-kselftest, linux-kernel
  Cc: linux-security-module, Paul Moore

Yama has no selftest coverage.  This series adds a new selftests/yama
directory: 1/2 provides the scaffolding and covers the ptrace_scope
sysctl and the attach matrix, 2/2 adds the PR_SET_PTRACER exception
tests.

The PR_SET_PTRACER lifecycle tests exercise the same grant, replacement
and revocation semantics as the recent tracer-lifetime fix linked below,
and pass both on mainline and with that fix applied.

Scope 3 is irreversible until reboot, so it is only tested when
ptrace_scope is already 3, or when YAMA_TEST_NO_ATTACH=1 opts in.
Privileged cases are skipped when the capability set does not allow
them, so the tests also run in restricted containers.

Tested on arm64 (QEMU/KVM, KASAN + lockdep): 10 rounds of both binaries
as root and as an unprivileged user, plus a final ptrace_scope=3 pass;
a boot with lsm=capability verifies that every test skips cleanly when
Yama is inactive.

Link: https://lore.kernel.org/r/20261123165357.4092273-1-bsdhenrymartin@gmail.com

Guicai Ma (2):
  selftests/yama: add ptrace_scope selftests
  selftests/yama: add PR_SET_PTRACER tests

 MAINTAINERS                                   |   1 +
 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/yama/.gitignore       |   3 +
 tools/testing/selftests/yama/Makefile         |  13 +
 tools/testing/selftests/yama/common.h         | 233 +++++++++
 tools/testing/selftests/yama/config           |   4 +
 .../selftests/yama/ptrace_scope_test.c        | 452 ++++++++++++++++++
 tools/testing/selftests/yama/ptracer_test.c   | 403 ++++++++++++++++
 8 files changed, 1110 insertions(+)
 create mode 100644 tools/testing/selftests/yama/.gitignore
 create mode 100644 tools/testing/selftests/yama/Makefile
 create mode 100644 tools/testing/selftests/yama/common.h
 create mode 100644 tools/testing/selftests/yama/config
 create mode 100644 tools/testing/selftests/yama/ptrace_scope_test.c
 create mode 100644 tools/testing/selftests/yama/ptracer_test.c

-- 
2.47.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-25 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 12:59 [PATCH 0/2] selftests/yama: add ptrace_scope and PR_SET_PTRACER tests Guicai Ma
2026-11-25 12:59 ` [PATCH 1/2] selftests/yama: add ptrace_scope selftests Guicai Ma
2026-11-25 12:59 ` [PATCH 2/2] selftests/yama: add PR_SET_PTRACER tests Guicai Ma
2026-11-25 13:06 ` [PATCH 0/2] selftests/yama: add ptrace_scope and " sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox