Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp12594088ybl; Sat, 28 Dec 2019 16:13:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyZe+Q53nKx1ah/WxtevSdvmnyqWg/NYptWeO6h+BFaoIHPeWwRFpJtJ/wPOpqYY1QB6xl/ X-Received: by 2002:a9d:6ac1:: with SMTP id m1mr53539049otq.101.1577578403789; Sat, 28 Dec 2019 16:13:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577578403; cv=none; d=google.com; s=arc-20160816; b=05iBMb+P54uEdeXGO/UOqvTxKFX+dRRYb0yeW/0TGhV6ZJ2EUVX4IOrmL2oCe+jM6f fYFnuVdc5wnikuypfDIIKBDmTNEc557DOXaCVk7fqcQV/12LZ5LJdiJetcf1DN/+9NHr gS2XF1ztESoC77pE069LrZ7EHsXILNEqKakED1ELd6D7ut93Zfb6swHSexuv17RaZ6r+ 4zyya9XH2CVHTsWj3uGVOWF5LxyUHzmSwIYgnyhpZjo3O6VR2DVdmqQxtdmdQuwwJRuS eoful+/sEztgFT5h/5IA98zh/hSlV/mCRu/4Z46dC3KB9cpmm87IE3nsUFNrArYU2jGf eShA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Vvh824TZBnegJvSkK9xRvfwQduMxT+onfQ7CGqFsH/0=; b=GYIWB4Xj3wi2Hwo8N6DHf0t1e74q2QOn6gANki7CP3i2G25kBjtOt5CauEhn4fHqjs Z0rhCBdSLqsAcBRiPshVqbvaHLw8dXF8OwjbouElefKoXtQsu2URWFGiBK/v8zlacKeW tDVEyhwQb4iKQ5rV4CAC2OacAK90LvVUTrDZ91sVZwRr+rzUrEYljJ7ZlUpbtnEu6xpD VpkyktoaVzUwWkLnadJOsgpi5jbNMeBPPBFEeN2baDXWP7vAzkvhBVSSZpqxtwUC2oaR GuZ/rRhnDiiW6DVZPwUvYVad5Zo12+Gxbt//O1NLX4cadk1x0MWvAKVWc9EmuRBJTpau g/Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b="Flo9H/by"; 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 p5si8763015otl.13.2019.12.28.16.12.51; Sat, 28 Dec 2019 16:13:23 -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="Flo9H/by"; 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 S1726307AbfL2ALI (ORCPT + 99 others); Sat, 28 Dec 2019 19:11:08 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45135 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbfL2ALI (ORCPT ); Sat, 28 Dec 2019 19:11:08 -0500 Received: by mail-ed1-f66.google.com with SMTP id v28so28852096edw.12 for ; Sat, 28 Dec 2019 16:11:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Vvh824TZBnegJvSkK9xRvfwQduMxT+onfQ7CGqFsH/0=; b=Flo9H/byGBYPx88NBrUk0p/S0kSMWqsqM20WhXB+e8Gs4ezuPPD6d5/sRxYjir/GdL qQtvdeJVpjFwAZA46/fvMNCnVIH+1g3wJjEybGdrC4kN3wkR0LA6w0TP6Lj8G4iJsVbm 5BEKgNETR7pEOOQNEQ/1FZoIwXB15hLxbGZeo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Vvh824TZBnegJvSkK9xRvfwQduMxT+onfQ7CGqFsH/0=; b=BgbvzedI7RA0AhzlxgnImoCFxKf6/THkbc34JVsRDnL1u2vGmPhsPCb79pPQ3Q6dCZ MwAoRaq/+SNd0e0KJL8ywURKCLCrYc+HgL0dFYDzTtf0ecHD9qqxliyBMU9a4R8in9jz uDMnDsgOCxpNg8kre7dML6SlMMxwG6QYN/PP6hxFJ8TDduzNdIM6uaZl85ofJSkXhht8 s36MffBxFFOPkIIxnPG8eypVrbxWWyYrbal/OXYG/OMTOTdx0kGj0AKgH7d1rr6wglzz QhXhNIyF5pxYsiCZ5d3WIRJiqJULls3LeDSPQiDXFVUcbYM6VRNQaBrOlDAW0GSIWtct AV2A== X-Gm-Message-State: APjAAAWtVTis0zlYoMciTyCy4NyOBzuflm+AFQm2YHcEOZZdnpORtgrS zgzEOgLARQrS/oiyq7XFnTTF++mcbl2aen1rgNX+5A== X-Received: by 2002:aa7:d714:: with SMTP id t20mr63876652edq.93.1577578265781; Sat, 28 Dec 2019 16:11:05 -0800 (PST) MIME-Version: 1.0 References: <20191228014837.GA31774@ircssh-2.c.rugged-nimbus-611.internal> <20191228181825.GB6746@cisco> In-Reply-To: <20191228181825.GB6746@cisco> From: Sargun Dhillon Date: Sat, 28 Dec 2019 19:10:29 -0500 Message-ID: Subject: Re: [PATCH v2 1/2] samples, selftests/seccomp: Zero out seccomp_notif To: Tycho Andersen Cc: LKML , Linux API , Jann Horn , Christian Brauner , Kees Cook , Aleksa Sarai Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 28, 2019 at 1:18 PM Tycho Andersen wrote: > > On Sat, Dec 28, 2019 at 01:48:39AM +0000, Sargun Dhillon wrote: > > The seccomp_notif structure should be zeroed out prior to calling the > > SECCOMP_IOCTL_NOTIF_RECV ioctl. Previously, the kernel did not check > > whether these structures were zeroed out or not, so these worked. > > > > Signed-off-by: Sargun Dhillon > > Cc: Kees Cook > > --- > > samples/seccomp/user-trap.c | 2 +- > > tools/testing/selftests/seccomp/seccomp_bpf.c | 2 ++ > > 2 files changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/samples/seccomp/user-trap.c b/samples/seccomp/user-trap.c > > index 6d0125ca8af7..0ca8fb37cd79 100644 > > --- a/samples/seccomp/user-trap.c > > +++ b/samples/seccomp/user-trap.c > > @@ -298,7 +298,6 @@ int main(void) > > req = malloc(sizes.seccomp_notif); > > if (!req) > > goto out_close; > > - memset(req, 0, sizeof(*req)); > > > > resp = malloc(sizes.seccomp_notif_resp); > > if (!resp) > > @@ -306,6 +305,7 @@ int main(void) > > memset(resp, 0, sizeof(*resp)); > > I know it's unrelated, but it's probably worth sending a patch to fix > this to be sizes.seccomp_notif_resp instead of sizeof(*resp), since if > the kernel is older this will over-zero things. I can do that, or you > can add the patch to this series, just let me know which. I was thinking about this, and initially, I chose to make the smaller change. I think it might make more sense to combine the patch, given that the memset behaviour is "incorrect" if we do it based on sizeof(*req), or sizeof(*resp). I'll go ahead and respin this patch with the change to call memset based on sizes. > > But in any case, this patch is: > > Reviewed-by: Tycho Andersen > > Cheers, > > Tycho