From nobody Fri Sep 25 16:51:03 2026 Received: from mail-pj2-f11.google.com (mail-pj2-f11.google.com [74.125.227.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 487B0489FCF for ; Thu, 10 Sep 2026 12:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789045023; cv=none; b=BgwgETzlSgiyLIuUV4EA07xK1OhCMaB5+CXT6g00mNzHOmkTjaSIJbI+t6SKrMvabyuPUqh7kDrd6XZxLDzAFniKHX44sRZLGtO3DqkjqBS4lCtmzWLwTr+kymp8WY4fjceCLc2JyGKN6lhpUxxPgQQ4nodqKOc3iIkH2KARaFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789045023; c=relaxed/simple; bh=0X+AdhuUJlHtyLQafhDA6Ri0tmdjnAfvmKJFKTMJlxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iqTcg2SyuIC10vZyJGr4Sngpj8Lm8A8rzCsHItBiMk656gUFLe65vIg+wFwW47KZoEjg+kTslvqIw/ROJyhFOML58gTcrOB4biOC/8CbiVwLvESuIynKitDk+IpQVM+XIYIe4NtwMfe7MB/xmfpfxxrpfo+7O7nCZShfnjJ48DE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lCo57O0E; arc=none smtp.client-ip=74.125.227.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lCo57O0E" Received: by mail-pj2-f11.google.com with SMTP id 98e67ed59e1d1-396a51b2605so2892771a91.0 for ; Thu, 10 Sep 2026 05:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789045020; x=1789649820; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HVOi/Y3C1iRUwyA09cZKyOyweLLbf7+xSIA4QpyhUZQ=; b=lCo57O0EZfDD/fYBtVv6D39Nfu+PniGRijWIaBH/JszGEVh1vFdW5VQ3IzdFs1qLuX ze6w4iEbmlwTg6IN+RyisvMLYwzAScF4Tuhes3NH1iYE6crnO9n3bB94kziAP9Qv9SpG M9ChfAjZmTWnsYdyI3zJ0mbZ4ptZaslrzD5/FFHEfCMbKnKi143kKilaI2kVvI8pMHc/ Tnu0P29swK5xxr0UQglMuF+BTe0DxpaCkBs62avNCU0xlvlfRJ6Y+LKTG5e56ZFNnlNP nky73R7X7V7yCz5v2I9v/pawjoL51kOgJe5Ag8jsqhJJNl78qWl93BQNzwDrBxFqpjQw dnGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789045020; x=1789649820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HVOi/Y3C1iRUwyA09cZKyOyweLLbf7+xSIA4QpyhUZQ=; b=mm8IuqF1ton3SD7KvAIACUxVUtPQogiTlUrq5cxUhhZmadexfb7VWcVv/3DvN+YQAy DsLQ3ExOqPcb6a2+D8aU23mrjR7BksOeHoD04VY4//zr/v43lDKWOh9z5YRIcVI2OPS7 W/THXD2c33AtfVheXuPuqp4kk52YAPlYNxc5Wj/5VZRatqF4lFQtUPhxfaw4lgl8IPuL OBTo81QM9u5mUfyn1WCscR7JslP940qZ20BAXiCtFaHB/tNQTjhTGWgJQ+rhTPnpJRG8 5dJID9y/j36ynV5y0CWajAFwfqefJtzMH1aR+Z2qTiGAGAjQ8Js4oK+BUKY3H8QX1pPX bTjw== X-Forwarded-Encrypted: i=1; AKwUvBywhhKXU3Zy2D8EFIRvydtHJwIbSzujk9/CQ/Vz6kHBAzypJ7nysGefhrPo/fwZWzpuLbXKfLf9utMRf84=@vger.kernel.org X-Gm-Message-State: AFuF++mwkUFX1TsWbCmG7H62WEw/yEf1iyLMsQnWdRYmwbbEe4HqVqF+ Zz98Smi2KfAfOKA1iX2X+vhc2YZNKrZqaAMHmaPTfbHZ1F+pFKbLNDGf X-Gm-Gg: AYBFou071zbm3YIG2JwTncsO2xGX3Cwl9guOettKTIfbXJUtz2LZwz+x+yFRh2Y7k0o 9Kzg4A2OgEJTnBekef0Occk7ZOmR6ZUm2MXgtZA3jhAlsjtwzBaqcaHSURiz8wP3fP2FXCzFxiE 0vX7/MGNwE9ZWLVSxXbXK6l/xnYm15MU7eOdR6Vwg2EQ9DUzqWxKckOZ0OrzQxoR/m41LfnyloA f2RQ7gU31iNSW8PQWpuHs1DURZIhMbcGdiVmZ7BV3aLdPzy3S7TfYE+zN/GYdz13LGpuKZ1cfOA GH4eQkMvcH3jIDl/Km67BcLeiTTgUX7X7jLNjVSqmVlOWVJ8gI1/I/tVN18zbGqytPYy5ZlRx86 FfI+OarpBJ32o0fU825LaxfpDgByp94ROCeN/kwVQJRrGhfLOj6AY+TjM3+SoKZEBYd94BJtmNa CxMkLe+8XMqTPfr9dKN8NaChCjwy/f1F4k910IjuBX1LneHVWh9yoyJ8sFCPQ5jukDRQHsug== X-Received: by 2002:a17:90b:4fc5:b0:37f:e1b6:4c7d with SMTP id 98e67ed59e1d1-39b26190c25mr61000735a91.6.1789045020263; Thu, 10 Sep 2026 05:57:00 -0700 (PDT) Received: from fedora ([69.5.53.41]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39d7e9014cbsm4800488a91.16.2026.09.10.05.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 05:56:59 -0700 (PDT) From: Tianyi Chen To: Andrew Morton , David Hildenbrand Cc: Shuah Khan , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Joel Savitz Subject: [PATCH v3 RESEND 1/2] selftests/mm: Reject invalid test selections before running tests Date: Thu, 10 Sep 2026 20:56:44 +0800 Message-ID: <20260910125645.285866-2-diannaaav@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260910125645.285866-1-diannaaav@gmail.com> References: <20260910125645.285866-1-diannaaav@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tianyi Chen 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 --- 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/self= tests/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: =20 example: ./run_vmtests.sh -t "hmm mmap ksm" EOF - exit 0 } =20 RUN_ALL=3Dfalse RUN_DESTRUCTIVE=3Dfalse TAP_PREFIX=3D"# " =20 +VM_SELFTEST_ITEMS=3D"default" + while getopts "aht:nd" OPT; do case ${OPT} in "a") RUN_ALL=3Dtrue ;; - "h") usage ;; + "h") usage; exit 0 ;; "t") VM_SELFTEST_ITEMS=3D${OPTARG} ;; "n") TAP_PREFIX=3D ;; "d") RUN_DESTRUCTIVE=3Dtrue ;; + "?") exit 1 ;; esac done shift $((OPTIND -1)) =20 -# default behavior: run all tests -VM_SELFTEST_ITEMS=3D${VM_SELFTEST_ITEMS:-default} +# Normalize whitespace so validation and test_selected() use the same name= s. +read -r -a selected_categories <<< "${VM_SELFTEST_ITEMS//$'\n'/ }" +VM_SELFTEST_ITEMS=3D"${selected_categories[*]}" +if [ -z "$VM_SELFTEST_ITEMS" ]; then + echo "No test categories specified" >&2 + exit 1 +fi + +if [ "$VM_SELFTEST_ITEMS" !=3D "default" ]; then + # Keep the documented category list as the source of valid names. + valid_categories=3D$(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 =20 test_selected() { if [ "$VM_SELFTEST_ITEMS" =3D=3D "default" ]; then --=20 2.55.0 From nobody Fri Sep 25 16:51:03 2026 Received: from mail-pj2-f11.google.com (mail-pj2-f11.google.com [74.125.227.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF6FF489FD0 for ; Thu, 10 Sep 2026 12:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789045025; cv=none; b=AQZmkA+dYbuZHBndqKh2LiwTU76K1NjQQ2U1FMAaxThj9zkhLTv35kgM+ReE6rH1Fczxcm14o0c0txvm4O8wGz71kjGTTLqZhHhvxrbSHEucUMwHe2YCgy8Yc3B871tTTbDjj9/vE7aoEulKiBFhl0MmQS4xlIow51uwtAaB2PI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789045025; c=relaxed/simple; bh=gFGy71C2eoTN3BD7btjLcX7mhlzhINqXiE6srCYAltI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DNy2rPUNiq4y6z18p0Z5Pykw0ay56pMjCYmUtzbl39y49eKw803i1DnXJ2dNOX2Ly0hBT6XGRr0iIVJfp0dr/VaS8i0eWdxiU9WrUw3DgJrxNz3phmGZcPRDTXmbqkmvEBaoDB0xHxMJi2mP45GdgizeWIcwnifEbjxuKaXm/C4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J8+gHB5w; arc=none smtp.client-ip=74.125.227.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J8+gHB5w" Received: by mail-pj2-f11.google.com with SMTP id 98e67ed59e1d1-396a51b2605so2892790a91.0 for ; Thu, 10 Sep 2026 05:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789045023; x=1789649823; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6mRdG/Kt6hS/eZlSBVQMx/QTMGuDSPWApxK45jZ1fD0=; b=J8+gHB5wwAr6//E0BhOL11YFPxdzUJiarVII9E3aM9VU64ickEQigEnEZFVDgRfjnS EQCGiyP7CpG75IH0k+aqbtEwrlQLGa4t7Xp+NahfAa6ihKy6m5GWYd4OprDvFFVL/zmr VAA01Y8uEQPhGGjIUwfSGlIN3YUjZthzX2oi7QHJUWfXzrTpW8mODBhNCCpMlfApGsxe rdUuNPiLUVYgF+uwq3lZAdr3+PGGMymrbtKk6H7DT2AHYVM1+iK7NPzfyZ9dwuffeRos YilS2cwL91tKDRAztHVFNh3Nvb1PT8+ehULBAhSXnY/Eed24t0KJHuHxnEsnSK3L4/Aj xTBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789045023; x=1789649823; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6mRdG/Kt6hS/eZlSBVQMx/QTMGuDSPWApxK45jZ1fD0=; b=r9mPZX/VFbDfE9CoB1+OwVETAw4pz2HQWkSKRgBYbYJ+Np4AvIEaNTSo+qFpNMpaxW G3sLu988jXZln4r2oAIPZrHJdy0GJSfZOwcEI4V8jPiCaUXMXVAkvSU/VRs4EHwa1PnX HyazMItSrlsuCe6RpQsqiFr19r4f7MqwgMWFKlPAf57CJV5BzqVBokiYMNgAom5F4lA1 DRoVI9vmaK1y/egbNmZ1E3LgIngd/bQkoo/re0KEgyouVRSFoIIXZ8XSDRbgK1Y2phYT pByeijxAKMF0a9S9o/72Uz13gWOv8i2m2aIwGe8SOppMmsbVg649T3NV3ET3cDcgQFQg yW1g== X-Forwarded-Encrypted: i=1; AKwUvBxUvEu/0I6qzDxtn71cFJ7wYALs2p1Eiqqm2jcIRvQD+bZwc8fmSqXkZGPWQdNdNJzLwc+8AZoxtPc9/s4=@vger.kernel.org X-Gm-Message-State: AFuF++mJ1kaRccCE+Qx/sOls0UAGTtlybiaIeXT+TLb1OIaFuGi7XvY+ vyZhHUWR9scvRbHyuQnVn+DwIhelIYhiQ3yavQUOFxsx6vdgKsB2A+On X-Gm-Gg: AYBFou3GQN3GD3miDxVXVA2NztWd2VvIcHS0GBGe1Yum5OjQUtbGrOHvb56Ua2PVNRa caFeTX+NKiqpN6E+RXqowQZ7OfwcbfGa25RA22ZmjlFnBHULDlY7HNGg2W8aoTnRuIbx4/Mc0hu tC21xOh5LRHfhDQxuHV0jG39AqfWFY2O2MA8eQRcfTFQWDaEAJddNUL1xa3f/vKOjOvMcrXNbxv ws51RsbmA37oSCMDewewGlRRWZALieyfosIIi7PfTefkyjcynT+ZivbNU7UrM5msM1EoCcrjjCi V8H+rHyJGz/yXmh5fAgkuneNwR0waAfeLtwYb2DE2OXysNmMWQNTzJTSxu5oYX9vthdFWIwwyRu MzBmVSEVjqE/lOigB5s3oEYcPO4Ueim5M+r6toQTXkMb9qXEyytGpU0XUAI+yH+XiIfeb3zSWQ/ YIjdmYeihRVhSPguxG4qEpCYKi5ADcjCf3ACMdGOGCKmkFCbrVg+7JnOSSRw== X-Received: by 2002:a17:90b:2d0b:b0:398:c794:ca26 with SMTP id 98e67ed59e1d1-39b263167f7mr60407420a91.25.1789045022916; Thu, 10 Sep 2026 05:57:02 -0700 (PDT) Received: from fedora ([69.5.53.41]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39d7e9014cbsm4800488a91.16.2026.09.10.05.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 05:57:02 -0700 (PDT) From: Tianyi Chen To: Andrew Morton , David Hildenbrand Cc: Shuah Khan , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Joel Savitz Subject: [PATCH v3 RESEND 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Date: Thu, 10 Sep 2026 20:56:45 +0800 Message-ID: <20260910125645.285866-3-diannaaav@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260910125645.285866-1-diannaaav@gmail.com> References: <20260910125645.285866-1-diannaaav@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tianyi Chen 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) Assisted-by: LLM Signed-off-by: Tianyi Chen --- 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/self= tests/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=3D"process_madv" run_test ./process_madv =20 CATEGORY=3D"vma_merge" run_test ./merge =20 -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 --=20 2.55.0