* [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup
@ 2026-09-09 14:54 Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Tianyi Chen @ 2026-09-09 14:54 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, using the category list
in usage(). Patch 2 gates memfd_secret preparation on category selection
and executable presence.
I am resending from my Gmail address after delivery problems with my
previous address. I could not confirm delivery of the earlier v3 posting.
This series is rebased onto current mm-unstable; both patches are unchanged
from v3 according to range-diff. Neither fix is present in current
mm-unstable, mm-stable or mainline.
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.
- Add David's Acked-by to patch 2, whose code is unchanged from v2.
Validation after rebasing:
- Bash syntax, whitespace and checkpatch checks passed.
- Ten invalid option/category invocations and help passed before setup.
- Rebuilt the four focused test binaries and ran the rebased script in an
x86-64 KVM guest. mmap, memfd_secret, combined selections, tab/newline
separators and repeated -t with the final selection taking effect all
passed.
- The guest lacks Yama. The ptrace_scope write condition was checked with
a disposable file at the expected path, not Yama policy enforcement.
This is focused validation, not a run of the complete MM selftest suite.
v2: https://lore.kernel.org/r/178886112560.138404.1278745290043112298.mm-cli-v2-0@tychen.cc
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] 8+ messages in thread* [PATCH v3 RESEND 1/2] selftests/mm: Reject invalid test selections before running tests
2026-09-09 14:54 [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
@ 2026-09-09 14:54 ` Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2 siblings, 0 replies; 8+ messages in thread
From: Tianyi Chen @ 2026-09-09 14:54 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
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] 8+ messages in thread* [PATCH v3 RESEND 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected
2026-09-09 14:54 [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
@ 2026-09-09 14:54 ` Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2 siblings, 0 replies; 8+ messages in thread
From: Tianyi Chen @ 2026-09-09 14:54 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
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] 8+ messages in thread
* Re: [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup
2026-09-09 14:54 [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
@ 2026-09-09 14:54 ` Tianyi Chen
2026-09-09 15:02 ` David Hildenbrand (Arm)
2 siblings, 1 reply; 8+ messages in thread
From: Tianyi Chen @ 2026-09-09 14:54 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
Hi David,
Following up on your review:
https://lore.kernel.org/r/d6ca7f47-39bb-43b4-92d6-63ccc148ebdd@kernel.org
> Who would set it at this point?
> Can't this just be
> VM_SELFTEST_ITEMS="default"
V3 makes that change: the default is initialized before getopts, and only
-t changes the selection. An explicit empty -t still fails validation.
Both patches use Assisted-by: LLM, and patch 2 carries your Acked-by.
I have resent v3 at the start of this new thread from my Gmail address
after delivery problems with my previous address. The patches are rebased
onto current mm-unstable without changes, and the focused parser and VM
selection tests passed again.
Thanks for the review and the ack.
Tianyi
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup
2026-09-09 14:54 ` [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
@ 2026-09-09 15:02 ` David Hildenbrand (Arm)
2026-09-09 15:04 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 8+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-09 15:02 UTC (permalink / raw)
To: Tianyi Chen, Andrew Morton
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
On 9/9/26 16:54, Tianyi Chen wrote:
> Hi David,
>
> Following up on your review:
> https://lore.kernel.org/r/d6ca7f47-39bb-43b4-92d6-63ccc148ebdd@kernel.org
>
>> Who would set it at this point?
>> Can't this just be
>> VM_SELFTEST_ITEMS="default"
>
> V3 makes that change: the default is initialized before getopts, and only
> -t changes the selection. An explicit empty -t still fails validation.
> Both patches use Assisted-by: LLM, and patch 2 carries your Acked-by.
>
> I have resent v3 at the start of this new thread from my Gmail address
> after delivery problems with my previous address. The patches are rebased
> onto current mm-unstable without changes, and the focused parser and VM
> selection tests passed again.
That is new:
$ b4 shazam https://lore.kernel.org/r/CACGbirR9PNt4uhqJFATsOWnwmsNb-v8zau-Rb+9Q5SZmY-=Vug@mail.gmail.com
Looking up https://lore.kernel.org/all/CACGbirR9PNt4uhqJFATsOWnwmsNb-v8zau-Rb%2B9Q5SZmY-%3DVug@mail.gmail.com/
Grabbing thread from lore.kernel.org/all/CACGbirR9PNt4uhqJFATsOWnwmsNb-v8zau-Rb%2B9Q5SZmY-%3DVug@mail.gmail.com/t.mbox.gz
Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 4 messages in the thread
Analyzing 14 code-review messages
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v3 1/2] selftests/mm: Reject invalid test selections before running tests
✓ [PATCH v3 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected
---
✓ Signed: DKIM/gmail.com
---
Total patches: 2
---
Applying: selftests/mm: Reject invalid test selections before running tests
Patch failed at 0001 selftests/mm: Reject invalid test selections before running tests
error: git diff header lacks filename information when removing 1 leading pathname component at /home/dishy/linux/.git/rebase-apply/patch:6
--
Cheers,
David
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup
2026-09-09 15:02 ` David Hildenbrand (Arm)
@ 2026-09-09 15:04 ` David Hildenbrand (Arm)
2026-09-09 15:25 ` Tianyi Chen
0 siblings, 1 reply; 8+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-09 15:04 UTC (permalink / raw)
To: Tianyi Chen, Andrew Morton
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
On 9/9/26 17:02, David Hildenbrand (Arm) wrote:
> On 9/9/26 16:54, Tianyi Chen wrote:
>> Hi David,
>>
>> Following up on your review:
>> https://lore.kernel.org/r/d6ca7f47-39bb-43b4-92d6-63ccc148ebdd@kernel.org
>>
>>> Who would set it at this point?
>>> Can't this just be
>>> VM_SELFTEST_ITEMS="default"
>>
>> V3 makes that change: the default is initialized before getopts, and only
>> -t changes the selection. An explicit empty -t still fails validation.
>> Both patches use Assisted-by: LLM, and patch 2 carries your Acked-by.
>>
>> I have resent v3 at the start of this new thread from my Gmail address
>> after delivery problems with my previous address. The patches are rebased
>> onto current mm-unstable without changes, and the focused parser and VM
>> selection tests passed again.
>
> That is new:
>
> $ b4 shazam https://lore.kernel.org/r/CACGbirR9PNt4uhqJFATsOWnwmsNb-v8zau-Rb+9Q5SZmY-=Vug@mail.gmail.com
> Looking up https://lore.kernel.org/all/CACGbirR9PNt4uhqJFATsOWnwmsNb-v8zau-Rb%2B9Q5SZmY-%3DVug@mail.gmail.com/
> Grabbing thread from lore.kernel.org/all/CACGbirR9PNt4uhqJFATsOWnwmsNb-v8zau-Rb%2B9Q5SZmY-%3DVug@mail.gmail.com/t.mbox.gz
> Checking for newer revisions
> Grabbing search results from lore.kernel.org
> Analyzing 4 messages in the thread
> Analyzing 14 code-review messages
> Checking attestation on all messages, may take a moment...
> ---
> ✓ [PATCH v3 1/2] selftests/mm: Reject invalid test selections before running tests
> ✓ [PATCH v3 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected
> ---
> ✓ Signed: DKIM/gmail.com
> ---
> Total patches: 2
> ---
> Applying: selftests/mm: Reject invalid test selections before running tests
> Patch failed at 0001 selftests/mm: Reject invalid test selections before running tests
> error: git diff header lacks filename information when removing 1 leading pathname component at /home/dishy/linux/.git/rebase-apply/patch:6
>
>
I think what's happening is that something in your mail sending path wraps long
lines and breaks the patch format.
--
Cheers,
David
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup
2026-09-09 15:04 ` David Hildenbrand (Arm)
@ 2026-09-09 15:25 ` Tianyi Chen
0 siblings, 0 replies; 8+ messages in thread
From: Tianyi Chen @ 2026-09-09 15:25 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz,
Tianyi Chen
Hi David,
> I think what's happening is that something in your mail sending path wraps long
> lines and breaks the patch format.
You were right. I reproduced the same b4 error using an externally
received copy: outbound delivery wrapped the diff header and removed
whitespace. The copy in my Gmail Sent folder was intact, so my earlier
check missed the corruption. Sorry for the trouble.
I have resent the unchanged series as text/plain attachments:
https://lore.kernel.org/r/CACGbirTvSoSeNSpMCBiifTdRKKDsKbgk7nfvh=09fHw2b0M4Ew@mail.gmail.com
I verified the externally received attachments through b4 and git am.
They reproduce the prepared tree and retain the original authorship
and your Acked-by on patch 2.
I will use this Gmail address for follow-up, given the delivery problems
with my previous address.
Thanks,
Tianyi
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup
@ 2026-09-10 12:56 Tianyi Chen
0 siblings, 0 replies; 8+ messages in thread
From: Tianyi Chen @ 2026-09-10 12:56 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
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.
The patches and commit messages are unchanged from v3. This resend uses
git send-email through Gmail's SMTP server to send the patches inline.
Before resending, I sent them to my SpaceMail mailbox and verified the
received contents and whitespace. Both patches passed git apply --check
and git am, and the resulting trees matched the original commits.
David, this is my first time setting up Gmail SMTP for patch submission.
I'm very sorry for the formatting problems I caused and for taking up
so much of your time. Thank you for your patience.
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
tools/testing/selftests/mm/run_vmtests.sh | 28 +++++++++++++++++++----
1 file changed, 23 insertions(+), 5 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-10 12:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 14:54 [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
2026-09-09 14:54 ` [PATCH v3 RESEND 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-09 15:02 ` David Hildenbrand (Arm)
2026-09-09 15:04 ` David Hildenbrand (Arm)
2026-09-09 15:25 ` Tianyi Chen
2026-09-10 12:56 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®