linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: Check for YAMA ptrace_scope configuraiton before modifying it
@ 2025-06-10 14:07 Mark Brown
  2025-06-10 17:16 ` Mike Rapoport
  2025-06-11 13:20 ` David Hildenbrand
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Brown @ 2025-06-10 14:07 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan, Mike Rapoport
  Cc: linux-mm, linux-kselftest, linux-kernel, Mark Brown

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.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/mm/run_vmtests.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index dddd1dd8af14..33fc7fafa8f9 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -429,7 +429,9 @@ CATEGORY="vma_merge" run_test ./merge
 
 if [ -x ./memfd_secret ]
 then
-(echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix
+if [ -f /proc/sys/kernel/yama/ptrace_scope ]; then
+	(echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix
+fi
 CATEGORY="memfd_secret" run_test ./memfd_secret
 fi
 

---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250605-selftest-mm-enable-yama-1541c2d2ddcd

Best regards,
-- 
Mark Brown <broonie@kernel.org>



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

* Re: [PATCH] selftests/mm: Check for YAMA ptrace_scope configuraiton before modifying it
  2025-06-10 14:07 [PATCH] selftests/mm: Check for YAMA ptrace_scope configuraiton before modifying it Mark Brown
@ 2025-06-10 17:16 ` Mike Rapoport
  2025-06-11 13:20 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2025-06-10 17:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: Andrew Morton, Shuah Khan, linux-mm, linux-kselftest,
	linux-kernel

On Tue, Jun 10, 2025 at 03:07:44PM +0100, Mark Brown wrote:
> 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.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  tools/testing/selftests/mm/run_vmtests.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index dddd1dd8af14..33fc7fafa8f9 100755
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -429,7 +429,9 @@ CATEGORY="vma_merge" run_test ./merge
>  
>  if [ -x ./memfd_secret ]
>  then
> -(echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix
> +if [ -f /proc/sys/kernel/yama/ptrace_scope ]; then
> +	(echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix
> +fi
>  CATEGORY="memfd_secret" run_test ./memfd_secret
>  fi
>  
> 
> ---
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
> change-id: 20250605-selftest-mm-enable-yama-1541c2d2ddcd
> 
> Best regards,
> -- 
> Mark Brown <broonie@kernel.org>
> 

-- 
Sincerely yours,
Mike.


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

* Re: [PATCH] selftests/mm: Check for YAMA ptrace_scope configuraiton before modifying it
  2025-06-10 14:07 [PATCH] selftests/mm: Check for YAMA ptrace_scope configuraiton before modifying it Mark Brown
  2025-06-10 17:16 ` Mike Rapoport
@ 2025-06-11 13:20 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2025-06-11 13:20 UTC (permalink / raw)
  To: Mark Brown, Andrew Morton, Shuah Khan, Mike Rapoport
  Cc: linux-mm, linux-kselftest, linux-kernel

On 10.06.25 16:07, Mark Brown wrote:
> 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.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 14:07 [PATCH] selftests/mm: Check for YAMA ptrace_scope configuraiton before modifying it Mark Brown
2025-06-10 17:16 ` Mike Rapoport
2025-06-11 13:20 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).