]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/selftests-skip-seccomp-get_metadata-test-if-not-real.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / queue-4.19 / selftests-skip-seccomp-get_metadata-test-if-not-real.patch
1 From 8801c62e0219568d5414dce8f514d7cf17eca0c8 Mon Sep 17 00:00:00 2001
2 From: Tycho Andersen <tycho@tycho.ws>
3 Date: Fri, 18 Jan 2019 17:12:15 -0700
4 Subject: selftests: skip seccomp get_metadata test if not real root
5
6 [ Upstream commit 3aa415dd2128e478ea3225b59308766de0e94d6b ]
7
8 The get_metadata() test requires real root, so let's skip it if we're not
9 real root.
10
11 Note that I used XFAIL here because that's what the test does later if
12 CONFIG_CHEKCKPOINT_RESTORE happens to not be enabled. After looking at the
13 code, there doesn't seem to be a nice way to skip tests defined as TEST(),
14 since there's no return code (I tried exit(KSFT_SKIP), but that didn't work
15 either...). So let's do it this way to be consistent, and easier to fix
16 when someone comes along and fixes it.
17
18 Signed-off-by: Tycho Andersen <tycho@tycho.ws>
19 Acked-by: Kees Cook <keescook@chromium.org>
20 Signed-off-by: Shuah Khan <shuah@kernel.org>
21 Signed-off-by: Sasha Levin <sashal@kernel.org>
22 ---
23 tools/testing/selftests/seccomp/seccomp_bpf.c | 6 ++++++
24 1 file changed, 6 insertions(+)
25
26 diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
27 index 83057fa9d391..14cad657bc6a 100644
28 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
29 +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
30 @@ -2920,6 +2920,12 @@ TEST(get_metadata)
31 struct seccomp_metadata md;
32 long ret;
33
34 + /* Only real root can get metadata. */
35 + if (geteuid()) {
36 + XFAIL(return, "get_metadata requires real root");
37 + return;
38 + }
39 +
40 ASSERT_EQ(0, pipe(pipefd));
41
42 pid = fork();
43 --
44 2.19.1
45