Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9111068ybl; Wed, 25 Dec 2019 13:50:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzYoIlQPaT/YafraVgTmInViupFKbC1WeWi62hQxRTfISmGgzz80//bJvdx9WMuu2cHWEYE X-Received: by 2002:a9d:3b23:: with SMTP id z32mr44702719otb.159.1577310634954; Wed, 25 Dec 2019 13:50:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577310634; cv=none; d=google.com; s=arc-20160816; b=ADsw/POBGgsDvCuqlpvm5DjFfGOS4OBpC+u47iiZpXU/L8o1OB2KcOKXfc6HDAeLQI Y+L7Jxyi7Pfv8nUwHzDiRB4jc+aaAmzJ/oxK5dXsmLcLnJ4txbKgIt1wkrP4Hz5594tv QSjdCs+Ga2C2lAwxjzfqYnQzuT7yG22qY1nu/+c4FAzAHFskiIc8RVyOTMCPtRy6jPZx zSrdC5hbXlDs7TqqSdjy89vT2B4VAZcKMOsFnB9JDeSMIouMgMwZThX0k1/cvLmPeZ+f SsX3K0eG2d9ttG+1dqiAQJXGQeFaUAnSotDrtRyPQxx0TL7PytYkW0D7AAkCotnhQlGv sJkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=3aSJZB0OJVXMfAC66n1zig6Ufda47bAnHowrO052PgA=; b=vXSfEyc+Yd1Vkf2LfeezTCjlHW+x/wiIl6lwFi+fRBCdz3vrzwt0DGpWup4+fmmTJy RqgttMzPrZtXWkuZJ9Erv8j5e3tCng/DeDT813oejXSrmKmSV+KDnIzeNTX8VVBKuCgK 8X3MluuCZd4vzy+DKx4+O/N4VcRH7sCLgTJL4Y+nKuEqqJyCuWg3joON7dkQpWjz57x4 hZ+oxN+frIg3k8Ae3SbkfApgPRu926/Uye4pU3kMmc+ziURdtEoQK7DDe2pQ97jcFWqA bowlPIJB7Y3JiwlGutXVS/s724YK0T7bzgfMhcqwd7ukUqMTdqz92yYIdurb8NiYa6BN bu0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=qJzF3OYA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si11726872oig.255.2019.12.25.13.50.22; Wed, 25 Dec 2019 13:50:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b=qJzF3OYA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726899AbfLYVpi (ORCPT + 99 others); Wed, 25 Dec 2019 16:45:38 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:40531 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbfLYVph (ORCPT ); Wed, 25 Dec 2019 16:45:37 -0500 Received: by mail-io1-f66.google.com with SMTP id x1so21880173iop.7 for ; Wed, 25 Dec 2019 13:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=3aSJZB0OJVXMfAC66n1zig6Ufda47bAnHowrO052PgA=; b=qJzF3OYAhdUoP9SNNoN6oh+i6RoA7XW1rf4IP/TBkNLuslgp4h4WhU95Zibilay4up ytryVQNI5KLtzBuEtBQ/NDSuByDRnGftfDrfFhV+7//t3TVVUlII8urB2bw9ECDpSUP6 KSGBDehQ/zyaVugSkZeLUWJeRn6vzI/+htg1c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=3aSJZB0OJVXMfAC66n1zig6Ufda47bAnHowrO052PgA=; b=Uu03jYmSW7cJnFkQSzvoa1w+IC89Ld87dNU6umJ3UzY/0hYIJBJwbTJYmSAXw+y3ww cYK4bHAsZ4+ZeWkLtLNl6KfKLIK04yn1df8/BuqAlkbYthoLKsVIbNv7nHutQunT90b7 ubWyY9+IZ86DPA/DWlu+yuJ5OtYGgQIzCAE+5GYequQ8kof2y1JyK4ZNuwLtxyK1yCOG d4idZ5lx5vYSbfUi6HsZv+zGtcg2NDkEScx8AYRNpnoNsxB8FkBvRJJj9FbssRVNGVSI y5kyHkG83ZmaoQvXgrXPxdYbbjI2+KLdqOr/NhjoFa0qo1RW2gA2G839Pvctq/0+tru8 HZWg== X-Gm-Message-State: APjAAAVpGCuAum+zOJLUJoIpN7l5R/3HClivDlBlu7MWBT6l7P0ht5gY NmQt727C+LwmCF0ABDyAtXAVQ3J/rTM= X-Received: by 2002:a5d:8782:: with SMTP id f2mr20237572ion.53.1577310336482; Wed, 25 Dec 2019 13:45:36 -0800 (PST) Received: from ircssh-2.c.rugged-nimbus-611.internal (80.60.198.104.bc.googleusercontent.com. [104.198.60.80]) by smtp.gmail.com with ESMTPSA id t23sm11576607ila.75.2019.12.25.13.45.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Dec 2019 13:45:35 -0800 (PST) Date: Wed, 25 Dec 2019 21:45:33 +0000 From: Sargun Dhillon To: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: tycho@tycho.ws, jannh@google.com, christian.brauner@ubuntu.com, keescook@chromium.org Subject: [PATCH] seccomp: Check flags on seccomp_notif is unset Message-ID: <20191225214530.GA27780@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is a small change in enforcement of the uapi for SECCOMP_IOCTL_NOTIF_RECV ioctl. Specificaly, the datastructure which is passed (seccomp_notif), has a flags member. Previously that could be set to a nonsense value, and we would ignore it. This ensures that no flags are set. Signed-off-by: Sargun Dhillon Cc: Kees Cook --- kernel/seccomp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 12d2227e5786..455925557490 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; + if (copy_from_user(&unotif, buf, sizeof(unotif))) + return -EFAULT; + + /* flags is reserved right now, make sure it's unset */ + if (unotif.flags) + return -EINVAL; + memset(&unotif, 0, sizeof(unotif)); ret = down_interruptible(&filter->notif->request); -- 2.20.1