* [PATCH RESEND v3 0/2] selftests/mm: Validate selections and scope memfd_secret setup
@ 2026-09-09 15:23 Tianyi Chen
2026-09-09 15:23 ` [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
2026-09-09 15:23 ` [PATCH RESEND v3 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
0 siblings, 2 replies; 6+ messages in thread
From: Tianyi Chen @ 2026-09-09 15:23 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
run_vmtests.sh can reach test setup after invalid options or category
selections. Its memfd_secret preparation can also change ptrace_scope
when that category was not selected.
Patch 1 rejects invalid selections before setup. Patch 2 gates
memfd_secret preparation on category selection and executable presence.
This replaces my earlier Gmail resend, whose outbound delivery wrapped
long lines and damaged patch whitespace. Thanks to David for reporting it.
The patches are unchanged and are attached as text/plain to preserve
their contents. I switched to Gmail because my previous address had
delivery problems.
Both patches remain based on mm-unstable b02c77c78ff7. The parser checks
and focused VM selection tests reported in the previous posting passed;
there are no code changes in this resend.
Changes in v3:
- Initialize VM_SELFTEST_ITEMS to "default" before getopts, as David
suggested. Only -t changes the selection.
- Use Assisted-by: LLM in both patches.
- Carry David's Acked-by on patch 2, unchanged from v2.
Tianyi Chen (2):
selftests/mm: Reject invalid test selections before running tests
selftests/mm: Only prepare ptrace_scope when memfd_secret is selected
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests
2026-09-09 15:23 [PATCH RESEND v3 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
@ 2026-09-09 15:23 ` Tianyi Chen
2026-09-09 15:33 ` David Hildenbrand (Arm)
2026-09-09 15:23 ` [PATCH RESEND v3 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
1 sibling, 1 reply; 6+ messages in thread
From: Tianyi Chen @ 2026-09-09 15:23 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
[-- Attachment #1: Type: text/plain, Size: 106 bytes --]
The unchanged patch is attached as text/plain to preserve long lines
and whitespace during mail delivery.
[-- Attachment #2: mm_patch1.patch --]
[-- Type: text/plain, Size: 2419 bytes --]
From: Tianyi Chen <hi@tychen.cc>
Date: Tue, 08 Sep 2026 11:21:21 +0800
getopts reports unknown options and missing arguments, but run_vmtests.sh
ignores its error result and continues with test setup. An empty -t
argument also falls back to the default selection, while unknown category
names can silently select no tests and still reach setup code.
Exit on getopts errors and validate category names against the existing
list in usage() before any test setup. Reject empty and whitespace-only
selections, and normalize category separators so validation and execution
agree. Initialize the default selection before parsing options so only -t
changes the selection.
Fixes: 85463321e726 ("selftests/vm: enable running select groups of tests")
Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
---
tools/testing/selftests/mm/run_vmtests.sh | 26 +++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index d09f9f6a384e..9e62ab4c6775 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -96,26 +96,44 @@ separated by spaces:
example: ./run_vmtests.sh -t "hmm mmap ksm"
EOF
- exit 0
}
RUN_ALL=false
RUN_DESTRUCTIVE=false
TAP_PREFIX="# "
+VM_SELFTEST_ITEMS="default"
+
while getopts "aht:nd" OPT; do
case ${OPT} in
"a") RUN_ALL=true ;;
- "h") usage ;;
+ "h") usage; exit 0 ;;
"t") VM_SELFTEST_ITEMS=${OPTARG} ;;
"n") TAP_PREFIX= ;;
"d") RUN_DESTRUCTIVE=true ;;
+ "?") exit 1 ;;
esac
done
shift $((OPTIND -1))
-# default behavior: run all tests
-VM_SELFTEST_ITEMS=${VM_SELFTEST_ITEMS:-default}
+# Normalize whitespace so validation and test_selected() use the same names.
+read -r -a selected_categories <<< "${VM_SELFTEST_ITEMS//$'\n'/ }"
+VM_SELFTEST_ITEMS="${selected_categories[*]}"
+if [ -z "$VM_SELFTEST_ITEMS" ]; then
+ echo "No test categories specified" >&2
+ exit 1
+fi
+
+if [ "$VM_SELFTEST_ITEMS" != "default" ]; then
+ # Keep the documented category list as the source of valid names.
+ valid_categories=$(usage | sed -n 's/^- //p')
+ for category in "${selected_categories[@]}"; do
+ if ! grep -Fxq -- "$category" <<< "$valid_categories"; then
+ echo "Unknown test category: $category" >&2
+ exit 1
+ fi
+ done
+fi
test_selected() {
if [ "$VM_SELFTEST_ITEMS" == "default" ]; then
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests
2026-09-09 15:23 ` [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
@ 2026-09-09 15:33 ` David Hildenbrand (Arm)
2026-09-10 10:25 ` Tianyi Chen
0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-09 15:33 UTC (permalink / raw)
To: Tianyi Chen, Andrew Morton
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
On 9/9/26 17:23, Tianyi Chen wrote:
> The unchanged patch is attached as text/plain to preserve long lines
> and whitespace during mail delivery.
So, b4 was able to apply it (and I briefly played with it and it's fine), but
for review using attachments is bad.
How did you send out the previous revision? Through b4 or git send-mail?
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests
2026-09-09 15:33 ` David Hildenbrand (Arm)
@ 2026-09-10 10:25 ` Tianyi Chen
2026-09-10 10:30 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 6+ messages in thread
From: Tianyi Chen @ 2026-09-10 10:25 UTC (permalink / raw)
To: David Hildenbrand, Andrew Morton
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
Hi David,
> How did you send out the previous revision? Through b4 or git send-mail?
The v3 sent from hi@tychen.cc on September 8 used git send-email via
SpaceMail SMTP. The inline Gmail resend on September 9 used Codex's
Gmail connector. The patches were generated with git format-patch.
The Gmail Sent copy was intact, but the copy received outside Gmail
had wrapped diff headers and altered whitespace. The attachments were
a workaround for that sending path. I agree they are inconvenient for
review.
Thanks,
Tianyi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests
2026-09-10 10:25 ` Tianyi Chen
@ 2026-09-10 10:30 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-10 10:30 UTC (permalink / raw)
To: Tianyi Chen, Andrew Morton
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
On 9/10/26 12:25, Tianyi Chen wrote:
> Hi David,
>
>> How did you send out the previous revision? Through b4 or git send-mail?
>
> The v3 sent from hi@tychen.cc on September 8 used git send-email via
> SpaceMail SMTP. The inline Gmail resend on September 9 used Codex's
> Gmail connector. The patches were generated with git format-patch.
>
> The Gmail Sent copy was intact, but the copy received outside Gmail
> had wrapped diff headers and altered whitespace. The attachments were
> a workaround for that sending path. I agree they are inconvenient for
> review.
Yeah, you have to find a way to fix that. I used to send patches through gmail's
smtp and it never resulted in something like this.
--
Cheers,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH RESEND v3 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected
2026-09-09 15:23 [PATCH RESEND v3 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-09 15:23 ` [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
@ 2026-09-09 15:23 ` Tianyi Chen
1 sibling, 0 replies; 6+ messages in thread
From: Tianyi Chen @ 2026-09-09 15:23 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
[-- Attachment #1: Type: text/plain, Size: 106 bytes --]
The unchanged patch is attached as text/plain to preserve long lines
and whitespace during mail delivery.
[-- Attachment #2: mm_patch2.patch --]
[-- Type: text/plain, Size: 1268 bytes --]
From: Tianyi Chen <hi@tychen.cc>
Date: Tue, 08 Sep 2026 11:21:50 +0800
The memfd_secret setup clears ptrace_scope whenever its test binary is
executable, even when a different category was selected. run_test() filters
the test invocation, but it does not protect the preceding setup.
Check the category selection before entering the memfd_secret block so
running unrelated categories does not change ptrace_scope. Keep the
existing executable check and the behavior when memfd_secret is selected.
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
---
tools/testing/selftests/mm/run_vmtests.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 9e62ab4c6775..9bbef9410ccc 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -370,7 +370,7 @@ CATEGORY="process_madv" run_test ./process_madv
CATEGORY="vma_merge" run_test ./merge
-if [ -x ./memfd_secret ]
+if test_selected "memfd_secret" && [ -x ./memfd_secret ]
then
if [ -f /proc/sys/kernel/yama/ptrace_scope ]; then
(echo 0 > /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-10 10:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 15:23 [PATCH RESEND v3 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-09 15:23 ` [PATCH RESEND v3 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
2026-09-09 15:33 ` David Hildenbrand (Arm)
2026-09-10 10:25 ` Tianyi Chen
2026-09-10 10:30 ` David Hildenbrand (Arm)
2026-09-09 15:23 ` [PATCH RESEND v3 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®