]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.97/revert-seccomp-add-a-selftest-for-get_metadata.patch
Linux 4.14.97
[thirdparty/kernel/stable-queue.git] / releases / 4.14.97 / revert-seccomp-add-a-selftest-for-get_metadata.patch
1 From 068966cd0a774e6336ddb5424dd65341320b488b Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 28 Jan 2019 14:40:49 -0500
4 Subject: Revert "seccomp: add a selftest for get_metadata"
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This reverts commit e65cd9a20343ea90f576c24c38ee85ab6e7d5fec.
10
11 Tommi T. Rrantala notes:
12
13 PTRACE_SECCOMP_GET_METADATA was only added in 4.16
14 (26500475ac1b499d8636ff281311d633909f5d20)
15
16 And it's also breaking seccomp_bpf.c compilation for me:
17
18 seccomp_bpf.c: In function ‘get_metadata’:
19 seccomp_bpf.c:2878:26: error: storage size of ‘md’ isn’t known
20 struct seccomp_metadata md;
21
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
23 ---
24 tools/testing/selftests/seccomp/seccomp_bpf.c | 61 -------------------
25 1 file changed, 61 deletions(-)
26
27 diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
28 index e350cf3d4f90..194759ec9e70 100644
29 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
30 +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
31 @@ -145,15 +145,6 @@ struct seccomp_data {
32 #define SECCOMP_FILTER_FLAG_SPEC_ALLOW (1UL << 2)
33 #endif
34
35 -#ifndef PTRACE_SECCOMP_GET_METADATA
36 -#define PTRACE_SECCOMP_GET_METADATA 0x420d
37 -
38 -struct seccomp_metadata {
39 - __u64 filter_off; /* Input: which filter */
40 - __u64 flags; /* Output: filter's flags */
41 -};
42 -#endif
43 -
44 #ifndef seccomp
45 int seccomp(unsigned int op, unsigned int flags, void *args)
46 {
47 @@ -2870,58 +2861,6 @@ TEST(get_action_avail)
48 EXPECT_EQ(errno, EOPNOTSUPP);
49 }
50
51 -TEST(get_metadata)
52 -{
53 - pid_t pid;
54 - int pipefd[2];
55 - char buf;
56 - struct seccomp_metadata md;
57 -
58 - ASSERT_EQ(0, pipe(pipefd));
59 -
60 - pid = fork();
61 - ASSERT_GE(pid, 0);
62 - if (pid == 0) {
63 - struct sock_filter filter[] = {
64 - BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW),
65 - };
66 - struct sock_fprog prog = {
67 - .len = (unsigned short)ARRAY_SIZE(filter),
68 - .filter = filter,
69 - };
70 -
71 - /* one with log, one without */
72 - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER,
73 - SECCOMP_FILTER_FLAG_LOG, &prog));
74 - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog));
75 -
76 - ASSERT_EQ(0, close(pipefd[0]));
77 - ASSERT_EQ(1, write(pipefd[1], "1", 1));
78 - ASSERT_EQ(0, close(pipefd[1]));
79 -
80 - while (1)
81 - sleep(100);
82 - }
83 -
84 - ASSERT_EQ(0, close(pipefd[1]));
85 - ASSERT_EQ(1, read(pipefd[0], &buf, 1));
86 -
87 - ASSERT_EQ(0, ptrace(PTRACE_ATTACH, pid));
88 - ASSERT_EQ(pid, waitpid(pid, NULL, 0));
89 -
90 - md.filter_off = 0;
91 - ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md));
92 - EXPECT_EQ(md.flags, SECCOMP_FILTER_FLAG_LOG);
93 - EXPECT_EQ(md.filter_off, 0);
94 -
95 - md.filter_off = 1;
96 - ASSERT_EQ(sizeof(md), ptrace(PTRACE_SECCOMP_GET_METADATA, pid, sizeof(md), &md));
97 - EXPECT_EQ(md.flags, 0);
98 - EXPECT_EQ(md.filter_off, 1);
99 -
100 - ASSERT_EQ(0, kill(pid, SIGKILL));
101 -}
102 -
103 /*
104 * TODO:
105 * - add microbenchmarks
106 --
107 2.19.1
108