Skip to content

Commit

Permalink
seccomp: Check that seccomp_notif is zeroed out by the user
Browse files Browse the repository at this point in the history
This patch is a small change in enforcement of the uapi for
SECCOMP_IOCTL_NOTIF_RECV ioctl. Specifically, the datastructure which
is passed (seccomp_notif) must be zeroed out. Previously any of its
members could be set to nonsense values, and we would ignore it.

This ensures all fields are set to their zero value.

Signed-off-by: Sargun Dhillon <[email protected]>
Reviewed-by: Christian Brauner <[email protected]>
Reviewed-by: Aleksa Sarai <[email protected]>
Acked-by: Tycho Andersen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Fixes: 6a21cc5 ("seccomp: add a return code to trap to userspace")
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
sargun authored and kees committed Jan 2, 2020
1 parent 88c13f8 commit 2882d53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,13 @@ static long seccomp_notify_recv(struct seccomp_filter *filter,
struct seccomp_notif unotif;
ssize_t ret;

/* Verify that we're not given garbage to keep struct extensible. */
ret = check_zeroed_user(buf, sizeof(unotif));
if (ret < 0)
return ret;
if (!ret)
return -EINVAL;

memset(&unotif, 0, sizeof(unotif));

ret = down_interruptible(&filter->notif->request);
Expand Down

0 comments on commit 2882d53

Please sign in to comment.