]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
selftests: skip seccomp get_metadata test if not real root
authorTycho Andersen <tycho@tycho.ws>
Sat, 19 Jan 2019 00:12:15 +0000 (17:12 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838116
[ Upstream commit 3aa415dd2128e478ea3225b59308766de0e94d6b ]

The get_metadata() test requires real root, so let's skip it if we're not
real root.

Note that I used XFAIL here because that's what the test does later if
CONFIG_CHEKCKPOINT_RESTORE happens to not be enabled. After looking at the
code, there doesn't seem to be a nice way to skip tests defined as TEST(),
since there's no return code (I tried exit(KSFT_SKIP), but that didn't work
either...). So let's do it this way to be consistent, and easier to fix
when someone comes along and fixes it.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <shuah@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
tools/testing/selftests/seccomp/seccomp_bpf.c

index ba15baa2061bb614b6433ced7abfaaa4ac21156d..2a87ccf6ceae51e670b756f56431d90c10e3ccce 100644 (file)
@@ -2680,6 +2680,12 @@ TEST(syscall_restart)
        struct utsname utsbuf;
 #endif
 
+       /* Only real root can get metadata. */
+       if (geteuid()) {
+               XFAIL(return, "get_metadata requires real root");
+               return;
+       }
+
        ASSERT_EQ(0, pipe(pipefd));
 
        child_pid = fork();