Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9697546ybl; Thu, 26 Dec 2019 03:53:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxL1IpeNm80SoazmIIiC8ZQOYP4mOyg2KrZq54mr2luUNQN82CPcX4eXcm8s3iy1Fa3q4Fs X-Received: by 2002:a9d:630d:: with SMTP id q13mr47199680otk.31.1577361221667; Thu, 26 Dec 2019 03:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577361221; cv=none; d=google.com; s=arc-20160816; b=I8aeEzSNJacBeldcDheMfbiacXRQxLqSvJIP+znguuTWr6A/jjws9mmwjSpdkZ7xWy jOtk6ujSj6/i8Al+lNR6mg/MMu/8uDrFJJoFiZczIqbbIs56Ty+bW1nTjEJ3P/tb/g/o EFBRf85Vh9ds2jHKQoVXEj9dSMsokdJFcmNEMtjeQDBk/VRw4wDukagxGwQsbmWPuqCB HpM/Jbi3LkEPdj5sWmXnysbWui3+xXAxMJK59m/Eyby69NTbyHV1/ezfoH2V0x/XSztH IaoHJTUWk1YU2owHNI1vNlN2l6mDKujYTs01IH29ImUc/MA8hCmkd+aZQF/uiXyBn08g RSMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=wqOv0DRJ8gWz4Zh4/LpAJNYe3I4lzBh1L8vh9LeuB/o=; b=VrzV0/eRvCR7MJ+w17z3X3gAmQq8MUYTKSRflgrBTvkrDbv6GgUWTAcyd0CPG1pWut bJJTewqiIQNxPTn2oCdUcbT7Ers8FQEHntMi965w2ewW2zGhzY1mRmOgRjPBgrwKL+FJ X8gcbodLmsYLjgBR7Kcn2sn/SVFd7jtARXHFcJqcsfs4gwrtp1T89Cn/n5jbgWbbtx+0 k/ky8a2Mt2n00OA+X/Wjpt3hoMyDrIhYC6gISMJDb3l92FMroqb2C0K6j7NcdbaQfhdS Juk0Vh23gR/3SpkZxNuA/68vYOSfPDwAks2REtHrOOuF1DkTHF10icrMPoNIu1cmLtpS y1Ag== ARC-Authentication-Results: i=1; mx.google.com; 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 b145si8030107oii.67.2019.12.26.03.53.29; Thu, 26 Dec 2019 03:53:41 -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; 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 S1726505AbfLZLwt (ORCPT + 99 others); Thu, 26 Dec 2019 06:52:49 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52130 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbfLZLwt (ORCPT ); Thu, 26 Dec 2019 06:52:49 -0500 Received: from p5b2a6c31.dip0.t-ipconnect.de ([91.42.108.49] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ikRh8-0004SH-SR; Thu, 26 Dec 2019 11:52:47 +0000 Date: Thu, 26 Dec 2019 12:52:45 +0100 From: Christian Brauner To: Sargun Dhillon Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, tycho@tycho.ws, jannh@google.com, keescook@chromium.org Subject: Re: [PATCH] seccomp: Check flags on seccomp_notif is unset Message-ID: <20191226115245.usf7z5dkui7ndp4w@wittgenstein> References: <20191225214530.GA27780@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191225214530.GA27780@ircssh-2.c.rugged-nimbus-611.internal> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 25, 2019 at 09:45:33PM +0000, Sargun Dhillon wrote: > 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 I'm fine with this since we soon want to make use of the flag argument when we add a flag to get a pidfd from the seccomp notifier on receive. The major users I could identify already pass in seccomp_notif with all fields set to 0. If we really break users we can always revert; this seems very unlikely to me though. One more question below, otherwise: Reviewed-by: Christian Brauner > --- > 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; > + Might it make sense to use err = copy_struct_from_user(&unotif, sizeof(unotif), buf, sizeof(unotif)); if (err) return err; This way we check that the whole struct is 0 and report an error as soon as one of the members is non-zero. That's more drastic but it'd ensure that other fields can be used in the future for whatever purposes. It would also let us get rid of the memset() below. > memset(&unotif, 0, sizeof(unotif)); > > ret = down_interruptible(&filter->notif->request); > -- > 2.20.1 >