Thread (11 messages) 11 messages, 3 authors, 2019-12-30

[PATCH v3 2/3] seccomp: Check that seccomp_notif is zeroed out by the user

flat view
STALE2489d LANDED: 3 (0M)

From: Sargun Dhillon <hidden>
Date: 2019-12-29 06:43:23
Also in: lkml
Subsystem: secure computing, the rest · Maintainers: Kees Cook, Linus Torvalds

3 review trailers; landed in mainline as 2882d53c9c6f on 2020-01-02.

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 <redacted>
Cc: Kees Cook <redacted>
Reviewed-by: Christian Brauner <redacted>
Reviewed-by: Aleksa Sarai <redacted>
Acked-by: Tycho Andersen <redacted>
---
 kernel/seccomp.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 12d2227e5786..b6ea3dcb57bf 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -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);
-- 
2.20.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help