mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
selftests/seccomp: Catch garbage on SECCOMP_IOCTL_NOTIF_RECV
commit e4ab5ccc357b978999328fadae164e098c26fa40 upstream.
This adds logic to the user_notification_basic test to set a member
of struct seccomp_notif to an invalid value to ensure that the kernel
returns EINVAL if any of the struct seccomp_notif members are set to
invalid values.
Signed-off-by: Sargun Dhillon <[email protected]>
Suggested-by: Christian Brauner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Fixes: 6a21cc50f0 ("seccomp: add a return code to trap to userspace")
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
de7cd9dfc5
commit
a61eb076cc
1 changed files with 12 additions and 1 deletions
|
|
@ -3147,7 +3147,18 @@ TEST(user_notification_basic)
|
|||
EXPECT_GT(poll(&pollfd, 1, -1), 0);
|
||||
EXPECT_EQ(pollfd.revents, POLLIN);
|
||||
|
||||
EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
|
||||
/* Test that we can't pass garbage to the kernel. */
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.pid = -1;
|
||||
errno = 0;
|
||||
ret = ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req);
|
||||
EXPECT_EQ(-1, ret);
|
||||
EXPECT_EQ(EINVAL, errno);
|
||||
|
||||
if (ret) {
|
||||
req.pid = 0;
|
||||
EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
|
||||
}
|
||||
|
||||
pollfd.fd = listener;
|
||||
pollfd.events = POLLIN | POLLOUT;
|
||||
|
|
|
|||
Loading…
Reference in a new issue