lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201020235126.1871815-12-fenghua.yu@intel.com>
Date:   Tue, 20 Oct 2020 23:51:16 +0000
From:   Fenghua Yu <fenghua.yu@...el.com>
To:     "Shuah Khan" <shuah@...nel.org>,
        "Reinette Chatre" <reinette.chatre@...el.com>,
        "Tony Luck" <tony.luck@...el.com>,
        "Babu Moger" <babu.moger@....com>,
        "James Morse" <james.morse@....com>,
        "Borislav Petkov" <bp@...en8.de>,
        "Thomas Gleixner" <tglx@...utronix.de>,
        "Ravi V Shankar" <ravi.v.shankar@...el.com>
Cc:     "linux-kselftest" <linux-kselftest@...r.kernel.org>,
        "linux-kernel" <linux-kernel@...r.kernel.org>,
        Fenghua Yu <fenghua.yu@...el.com>
Subject: [PATCH v3 11/21] selftests/resctrl: Abort running tests if not root user

Running any resctrl unit test involves writing to resctrl file system and
only a root user has permission to write to resctrl FS. Resctrl test suite
before running any test checks for the privilege of the user and if it's
not a root user, the test suite prints a warning and continues attempting
to run tests.

Attempting to run any test without root privileges will fail as below

TAP version 13
ok kernel supports resctrl filesystem
.................
not ok mounting resctrl to "/sys/fs/resctrl"
not ok MBA: schemata change

Hence, don't attempt to run any test if the user is not a root user and
change the warning message to a bail out message to comply with TAP 13
standards.

Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test")
Signed-off-by: Fenghua Yu <fenghua.yu@...el.com>
---
 tools/testing/selftests/resctrl/resctrl_tests.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index cab69ed8c67d..f4867a81eee6 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -125,8 +125,10 @@ int main(int argc, char **argv)
 	 * 1. We write to resctrl FS
 	 * 2. We execute perf commands
 	 */
-	if (geteuid() != 0)
-		printf("# WARNING: not running as root, tests may fail.\n");
+	if (geteuid() != 0) {
+		printf("Bail out! not running as root, abort testing\n");
+		goto out;
+	}
 
 	/* Detect AMD vendor */
 	detect_amd();
-- 
2.29.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ