From patchwork Fri Feb 9 20:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13551786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4E31C4828F for ; Fri, 9 Feb 2024 20:23:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16B086B0071; Fri, 9 Feb 2024 15:23:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11BD86B0072; Fri, 9 Feb 2024 15:23:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F24DD6B0074; Fri, 9 Feb 2024 15:23:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E38886B0071 for ; Fri, 9 Feb 2024 15:23:00 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B885381114 for ; Fri, 9 Feb 2024 20:23:00 +0000 (UTC) X-FDA: 81773389320.28.CD604F9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id E89711C0013 for ; Fri, 9 Feb 2024 20:22:57 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VILm83tG; spf=pass (imf20.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707510178; a=rsa-sha256; cv=none; b=oRKfgyLBLQpxNAFcXzxIzrTK2ZglyrXd6vZULenaof1QKhQ12X2GhB4Mev0y5DdeaGFTSj w486uZGwc3RLgHvclKCOPVqqToAfmpbmcZtDfnexy4+PUwZt7YCZ27C0rUfQ9dK9TlqQAE EkemxrFpK59mMsdqNpMJTRNtot0x5dk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VILm83tG; spf=pass (imf20.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707510178; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=haTz7vGeTtUdMChm3Kq0XW4irGcp+LjPFH2fjf0bf2g=; b=NR5Bd+QIoXauoi7Xpipb5wRR5x2t69zpHvuA0FelGpI37n2Gk2gg64hTT3p1/LzNsol4Qd M/cjrQCKKL9geS371bIv9oJKY65Kmc8WTU/kY4KRVLqt8n3BePH8Cj4yauk23L5j5nzX7S etQSmXxMKKFvoFliAHk3CdGe6ECA/a8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E7A9561DA5; Fri, 9 Feb 2024 20:22:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19C39C433F1; Fri, 9 Feb 2024 20:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707510176; bh=Vww2Jj+v4Z8QiE6rCC7eLelQulPvEW9AU9xCOOc5Lhs=; h=From:Date:Subject:To:Cc:From; b=VILm83tG07I926TyXMoIq7o0EQH9hCwIgF/fp3XDX/JF2nr46v6yuLxuldO2ZvcOf J6asXPk7Hjegdp1jJKAfaQEIKcLZslgCR/ryNI6E7g0jEVFlKAJD2rWG3IgemaA/8F mx7RMzb0uFJ2MAtL2G/3/E5SfWXBJdYMwmm8v0Iu1wPIvbeN715hiH2iYUgrkISg7k 5AGJaT8k/lEanSJTYbIDHggvVcGWVlXEz/7st9y41Yt3P39MtWP1cXUZ71Y2PuyP+I sYfSY9Y0NEPSCIB0UkkqCV+WLfSCugyPjwoF89e8dy+My11N9jc31x6Dx+K5ZCxB+b zUcMIgipFn2uw== From: Mark Brown Date: Fri, 09 Feb 2024 20:21:52 +0000 Subject: [PATCH] selftests/mm: Don't needlessly use sudo to obtain root in run_vmtests.sh MIME-Version: 1.0 Message-Id: <20240209-kselftest-mm-check-deps-v1-1-19b09b151522@kernel.org> X-B4-Tracking: v=1; b=H4sIAF+JxmUC/x3MSwqAMAxF0a1IxgZqUVC3Ig6kfdXgl0ZEEPduc XgG9z6kiAKlNnso4hKVfUso8ozcNGwjWHwyWWNLY03Ds2IJJ/TkdWU3wc3scSibYqhthSrAl5T qIyLI/Z+7/n0/aEhrBmkAAAA= To: Andrew Morton , Shuah Khan Cc: Ryan Roberts , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1989; i=broonie@kernel.org; h=from:subject:message-id; bh=Vww2Jj+v4Z8QiE6rCC7eLelQulPvEW9AU9xCOOc5Lhs=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlxomdxcmkOMP7U5xLlUuVTjCBZ0WrLPGtq+XfL 3p9ITNu54yJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZcaJnQAKCRAk1otyXVSH 0KH6B/9ApTHhrLOmnmotvLBAK11wu+cHt8ITHTFopBl8aopyk+Y7JyvT+YhnNUxRO8FrGN1labO 8apCpf/+yNMZD9meVzb92MkvfZjyXC3UqaEMva5dlT8adWtGeGBNHQoMen/OJiPm5Xz7taVADj4 itQgs/XjjLYGzZmj6hyA2ch15zqZgAs+uJZpX8nKXXuUkIjEkJFk0c6u5/0FGaHr7QBTFSJUsaG mPOH/CqmlDEUQQrtYxc+sKfUxMz+Czj7XmSZ3Fspo8k7CeQv6J8DpHklaV5Cv3SAK8taXiSx/eN xsEwQvOvjckH5GCqTeVhp6LVYowJlSr/2TnH+q3oWhqlcsoJ X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E89711C0013 X-Stat-Signature: hy1n36c6ortgtfwcan9fqu1w7dikebwe X-Rspam-User: X-HE-Tag: 1707510177-291860 X-HE-Meta: U2FsdGVkX1+OxvfLSOkNoodqJKthRKmuEo2vLwypAa7lNmIkBtTuIS5bxKqPfn3V8hOu2HWiKUs5LyFv2HXuIBzV778txxY7VPvkD3fmi2IzhdreiqdQOUTjPlyuKWeR4jiy/w2R8KXztNPNKkYBUIHnyJ8LHgYVLPk54Gs3ce0yaf4B1iQC8g+/nBcfI3UB+ac9KBt7trEud81ZmSefEvA655ZTgWDKXaSX34uvzfHr37t/FJ0NvmVX5fxzTTJrjEAZDhg1LVB4FMfIdVqcphN4h1A4Xgg/kcYCynMir9whDTGszYjBO7uQR7qNgiayDPNkiC4BEdi9vyTy4ywAUvutSskgjrMRclp0NlbyN3/f2Z1eFVVqOldZ5MIsqSu8WB8TPfPFUPv04lU1ayjnHEf+EvkDkT57BOfeJGKb4gURjKujieEkmOFL9OE0fLMBvrC6TSj5u6/pw1rsD3mYhuRdQBP+RJvqzn83Q9FH+AT8mmhmVpm4j7eBDswS4u7761i/5QHQ93IL9kPe70EDtJWdF1dBn1Z4LZAvJfx9PNhgwPVc7rxWOK5t3gFwB4AUcy47JAjRHhCpuCj800trFQsaW4XX8N4gFC0Bc+u0Dtic9AhGDdrcD3UgBM5BqbBa2EnIeknrylVe5rRC7sC+Koo6twIga2Q/nvMmZH1XQOQMzfPUcmxQ2iY6BxZpvl7dpa6UrevotBm0btl2YVOM4IPTntiRHo8E87JI04nIHqm6GHc2F23XlLIvjccu/wqqVBNfYKh13ONQvzL+xZr8iSkCxY9XH6WpseHW7+cw5vgkUNyuu/1lzqYIB7+FMR/giwqw/yPw/zcedwNGlVO3R6eaDsAizMcEI4LsDPU/stjLdhopmzgPklr9X8pg9RF8qH6JU+K8AyHCUuFjsz8z5XeGtgIsTZu0LyUEKhO2crsMEgAQDldKQaVnJ5ZMtIDP/wDvzCl7VbWJ0g8aHIP wMdyzdhu AWOMNHHr5iX8k4YAGV7ld87a8rYf+Sy6CGqMKflQvA28ES/Lvyyf5I52rCg8LYhp0rnVeyza4izP2V5LvLCCKISp7XoFaCWA+imoB2pdwGNodhPrKbiF4j1gyG7FoKc3r3jKQwko4XgrqpyTW8uHvKYAQSCEfioer0esgq0zo+9acRlYA4xqJhuTyJo4dpl5CKEbDD4e+THYYDM0ROv0ohBGxAU1Vn/lyd6prtWhNwtiLCh9rEfBv2OfJgH1LQU8XAgzuDi4tfDURF1EEUibnjv7tUcj+CUg1hg8Ss55FDFuafaM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When opening yama/ptrace_scope we unconditionally use sudo to ensure we are running as root, resulting in failures if running in a minimal root filesystem where sudo is not installed. Since automated test systems will typically just run all of kselftest as root (and many kselftests rely on this for full functionality) add a check to see if we're already root and only invoke sudo if not. Since I am unclear what the intended effect of the command being run is I have not added any error handling for the case where we fail to obtain root. Signed-off-by: Mark Brown --- tools/testing/selftests/mm/run_vmtests.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) --- base-commit: 445a555e0623387fa9b94e68e61681717e70200a change-id: 20240209-kselftest-mm-check-deps-01a825e5fed4 Best regards, diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index fe140a9f4f9d..c8ca830dba93 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -248,6 +248,17 @@ run_test() { echo "TAP version 13" | tap_output +HAVE_ROOT=0 +if [ "$(id -u)" = "0" ]; then + AS_ROOT= + HAVE_ROOT=1 +elif [ "$(command -v sudo)" != "" ]; then + AS_ROOT=sudo + HAVE_ROOT=1 +else + echo # WARNING: Unable to run as root +fi + CATEGORY="hugetlb" run_test ./hugepage-mmap shmmax=$(cat /proc/sys/kernel/shmmax) @@ -363,7 +374,8 @@ CATEGORY="hmm" run_test bash ./test_hmm.sh smoke # MADV_POPULATE_READ and MADV_POPULATE_WRITE tests CATEGORY="madv_populate" run_test ./madv_populate -(echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix +# FIXME: What if we can't get root? +(echo 0 | ${AS_ROOT} tee /proc/sys/kernel/yama/ptrace_scope 2>&1) | tap_prefix CATEGORY="memfd_secret" run_test ./memfd_secret # KSM KSM_MERGE_TIME_HUGE_PAGES test with size of 100