Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm: check for YAMA ptrace_scope configuraiton before modifying it

When running the memfd_secret test run_vmtests.sh unconditionally tries
to confgiure the YAMA LSM's ptrace_scope configuration, leading to an error
if YAMA is not in the running kernel:

# ./run_vmtests.sh: line 432: /proc/sys/kernel/yama/ptrace_scope: No such file or directory
# # ----------------------
# # running ./memfd_secret
# # ----------------------

Check that this file is present before trying to write to it.

The indentation here is a bit odd, and it doesn't seem great that we
configure but don't restore ptrace_scope.

Link: https://lkml.kernel.org/r/20250610-selftest-mm-enable-yama-v1-1-0097b6713116@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mark Brown and committed by
Andrew Morton
ba785855 4ff52d4a

+3 -1
+3 -1
tools/testing/selftests/mm/run_vmtests.sh
··· 429 429 430 430 if [ -x ./memfd_secret ] 431 431 then 432 - (echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix 432 + if [ -f /proc/sys/kernel/yama/ptrace_scope ]; then 433 + (echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix 434 + fi 433 435 CATEGORY="memfd_secret" run_test ./memfd_secret 434 436 fi 435 437