aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSargun Dhillon <[email protected]>2019-12-28 22:24:49 -0800
committerKees Cook <[email protected]>2020-01-02 13:03:42 -0800
commit88c13f8bd71472fbab5338b01d99122908c77e53 (patch)
tree05744afd8a844eb7d3c135832cf19e3a988d8722
parent771b894f2f3dfedc2ba5561731fffa0e39b1bbb6 (diff)
selftests/seccomp: Zero out seccomp_notif
The seccomp_notif structure should be zeroed out prior to calling the SECCOMP_IOCTL_NOTIF_RECV ioctl. Previously, the kernel did not check whether these structures were zeroed out or not, so these worked. This patch zeroes out the seccomp_notif data structure prior to calling the ioctl. Signed-off-by: Sargun Dhillon <[email protected]> Reviewed-by: Tycho Andersen <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace") Cc: [email protected] Signed-off-by: Kees Cook <[email protected]>
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 6944b898bb53..f53f14971bff 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -3278,6 +3278,7 @@ TEST(user_notification_signal)
close(sk_pair[1]);
+ memset(&req, 0, sizeof(req));
EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
EXPECT_EQ(kill(pid, SIGUSR1), 0);
@@ -3296,6 +3297,7 @@ TEST(user_notification_signal)
EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_SEND, &resp), -1);
EXPECT_EQ(errno, ENOENT);
+ memset(&req, 0, sizeof(req));
EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
resp.id = req.id;