[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191228014849.GA31783@ircssh-2.c.rugged-nimbus-611.internal>
Date: Sat, 28 Dec 2019 01:48:51 +0000
From: Sargun Dhillon <sargun@...gun.me>
To: linux-kernel@...r.kernel.org, linux-api@...r.kernel.org
Cc: tycho@...ho.ws, jannh@...gle.com, christian.brauner@...ntu.com,
keescook@...omium.org, cyphar@...har.com
Subject: [PATCH v2 2/2] seccomp: Check that seccomp_notif is zeroed out by
the user
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.
This relies on the seccomp_notif datastructure to not have
any unnamed padding, as it is valid to initialize the datastructure
as:
struct seccomp_notif notif = {};
This only initializes named members to their 0-value [1].
[1]: https://lore.kernel.org/lkml/20191227023131.klnobtlfgeqcmvbb@yavin.dot.cyphar.com/
Signed-off-by: Sargun Dhillon <sargun@...gun.me>
Cc: Kees Cook <keescook@...omium.org>
---
kernel/seccomp.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 12d2227e5786..4fd73cbdd01e 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -1026,6 +1026,12 @@ static long seccomp_notify_recv(struct seccomp_filter *filter,
struct seccomp_notif unotif;
ssize_t ret;
+ 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
Powered by blists - more mailing lists