Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2563913ybt; Tue, 16 Jun 2020 09:07:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLswC3YfnMLRzf8H9wavh/BWwKe1Jdg98r6jd23vj/HIB1nucaWwHcD4kTsP8UaV9OVa6r X-Received: by 2002:a50:9517:: with SMTP id u23mr3167348eda.332.1592323662149; Tue, 16 Jun 2020 09:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592323662; cv=none; d=google.com; s=arc-20160816; b=SWBXJcJ3oWDmdlPbzfCh4lHLnqXBOOp3pPOvfMU0Kb1wj6wfwkBZXX7Wf5Js1OAskt gwBXpyeA1R1lLQOLOC5HHBh8Na5EM8MoZQlmZX/dndZ1jfvZc3Jq7Q96C6RhsttB/Oij NbvYMtUC30GSliDkEdwhd4QnJHd/OrcM4HNRWbd6Zr1I63eNxIhnjwML6ScJiYW2TCH1 L1ETpeKfvjlmUwPT2GF2avNzdJKzqbMyYOPGtzP/oQGURNCFEc45VSBsKciQOy+Nx9Kp X10uGx+BnL4kEFbEi2aff/BUrywrhnoov8cccQWRVF/9e6KpPNBhlG2ujhasIzlFL2im SssA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=GsZMacKtpesOxP+a2myMr99YbAG58BqzpuI3p66lyWE=; b=xhDuV38YlBSD/v6fCcvNEhF/bB9XSOqpK//mzd6lpXgfuxBmOVC5CVmPB3ag8xdfkJ TrNPtFGC9c1yXaCybki3HY9fWYXBdiUwVr9fGgM/GurduWB7AzUUAnTuYcePHFTdaqPQ 9OLbA59JtYVpQHgyXEjTwn9ZLsNN+IszCRyADikfqYowCdzTTT+iqg1AJIhDKPFsoTGH WJ1dbtwIEZa3zGpNFPc7Y4F0uvIJZg/Igsfr+wuJiJH1tXWNQc/5Qkb06sV061LW6FXi W2FVxETSxyn15ksQB9PFWll5Cyd52jPGpQQjLS+NYiUrJy0U9bGcK3Cc7ThoXNWKsKwO KGbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=U+rVcwzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si10273856ejj.564.2020.06.16.09.07.19; Tue, 16 Jun 2020 09:07:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=U+rVcwzv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733007AbgFPQFh (ORCPT + 99 others); Tue, 16 Jun 2020 12:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733059AbgFPQFc (ORCPT ); Tue, 16 Jun 2020 12:05:32 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A2BFC0613ED for ; Tue, 16 Jun 2020 09:05:32 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id d4so2392413pgk.4 for ; Tue, 16 Jun 2020 09:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GsZMacKtpesOxP+a2myMr99YbAG58BqzpuI3p66lyWE=; b=U+rVcwzvOxiugEYzwFEOsUTyIYC0zrD9L//KqbY3KLh6kAWaKOVLW6S2PEBZNkUzZB Va/ID/Lx0jY7fHPp5zQPHHxv/Ln+/ZqNNagq0jWU0rfjSlk7wKKfPbUbnKanRNPb4MXv BPQ+ZtNfKAAI/vlY8WCybDSIj/et0xHDCOIHg= 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:references :mime-version:content-disposition:in-reply-to; bh=GsZMacKtpesOxP+a2myMr99YbAG58BqzpuI3p66lyWE=; b=tXvwi784gwsx55ZfFIMhvM5U4Z7ZBtQS3g71Zr2CFGlCl/DgkjBbFtlXRFeheWr2l4 ItjW1I2nW1Hp4AiGguUUN/nq62cx+hsijRcBymJMoXCVpP1RinqHoKRxeJkOsU5YhDy4 770GPpYaV/c+4ZOYFbtGRXX5qfYQjFXZsqqCwJ8Z5WRZfFer/WR3qmBVRnfTiBDdCLsi 21vYn/f1MU8TAQ7Lax8HOC5W6Wd0GPB01/awU64/oTiNsAciS2BUFHs1rjvraVFBVzRw 3wrHkvDmTEygmKMO5BdEpVzg1KAp1CxE/zNFZ29agEYrjDcPTcvcrURCVN/1IzyJtOJ9 m8tQ== X-Gm-Message-State: AOAM530bANXNt5E7hGdr07Jnpgit40FlOFVSfr0Un7p/lIDzD4HMU6F5 Wf6H6uPjwYtvlDKReL33Fnl/lA== X-Received: by 2002:a63:1b4b:: with SMTP id b11mr2541719pgm.243.1592323531730; Tue, 16 Jun 2020 09:05:31 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 140sm17823314pfz.154.2020.06.16.09.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2020 09:05:30 -0700 (PDT) Date: Tue, 16 Jun 2020 09:05:29 -0700 From: Kees Cook To: Tycho Andersen Cc: linux-kernel@vger.kernel.org, Sargun Dhillon , Christian Brauner , "David S. Miller" , Christoph Hellwig , Jakub Kicinski , Alexander Viro , Aleksa Sarai , Matt Denton , Jann Horn , Chris Palmer , Robert Sesek , Giuseppe Scrivano , Greg Kroah-Hartman , Andy Lutomirski , Will Drewry , Shuah Khan , netdev@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v4 10/11] seccomp: Switch addfd to Extensible Argument ioctl Message-ID: <202006160904.A30F2C5B9E@keescook> References: <20200616032524.460144-1-keescook@chromium.org> <20200616032524.460144-11-keescook@chromium.org> <20200616145546.GH2893648@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200616145546.GH2893648@cisco> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 16, 2020 at 08:55:46AM -0600, Tycho Andersen wrote: > On Mon, Jun 15, 2020 at 08:25:23PM -0700, Kees Cook wrote: > > This patch is based on discussions[1] with Sargun Dhillon, Christian > > Brauner, and David Laight. Instead of building size into the addfd > > structure, make it a function of the ioctl command (which is how sizes are > > normally passed to ioctls). To support forward and backward compatibility, > > just mask out the direction and size, and match everything. The size (and > > any future direction) checks are done along with copy_struct_from_user() > > logic. Also update the selftests to check size bounds. > > > > [1] https://lore.kernel.org/lkml/20200612104629.GA15814@ircssh-2.c.rugged-nimbus-611.internal > > > > Signed-off-by: Kees Cook > > --- > > include/uapi/linux/seccomp.h | 2 - > > kernel/seccomp.c | 21 ++++++---- > > tools/testing/selftests/seccomp/seccomp_bpf.c | 40 ++++++++++++++++--- > > 3 files changed, 49 insertions(+), 14 deletions(-) > > > > diff --git a/include/uapi/linux/seccomp.h b/include/uapi/linux/seccomp.h > > index c347160378e5..473a61695ac3 100644 > > --- a/include/uapi/linux/seccomp.h > > +++ b/include/uapi/linux/seccomp.h > > @@ -118,7 +118,6 @@ struct seccomp_notif_resp { > > > > /** > > * struct seccomp_notif_addfd > > - * @size: The size of the seccomp_notif_addfd structure > > * @id: The ID of the seccomp notification > > * @flags: SECCOMP_ADDFD_FLAG_* > > * @srcfd: The local fd number > > @@ -126,7 +125,6 @@ struct seccomp_notif_resp { > > * @newfd_flags: The O_* flags the remote FD should have applied > > */ > > struct seccomp_notif_addfd { > > - __u64 size; > > Huh? Won't this break builds? Only if they use addfd without this patch? :) Are you saying I should collapse this patch into the main addfd and test patches? -- Kees Cook