Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2697184ybk; Mon, 18 May 2020 05:55:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD5Cm4cp90DQyZSO3Cpwl7MrmpWub4Yiz8xvPmYA09VvyrtMhySANcRbfc0/O3kstFm7Nl X-Received: by 2002:a17:906:57d6:: with SMTP id u22mr14357386ejr.49.1589806537575; Mon, 18 May 2020 05:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589806537; cv=none; d=google.com; s=arc-20160816; b=jhZMB79o6uh/bfmmp97EE+KXzJo4pKEHe965RRqeKVYkt17WG8TlK1inr97Sqj/FiW eDhlnEVraBkvZUDxtu82qerUJd5mRBb6vk4IihkMpezJcerza12n87ZfMckQLeLN0sKx G8Zmh4M0KorWGudQNwHU7n8jQn1MwiDGgPeCp3POmXWpleviDc5l7iCh7QZf4pFKhdvo 4aVXpYhxJkVo4lH5wSdmv0oKGpPh4U3AUbKocCUn8fVS7Eteltcfh8SEZCobdZDijHz7 B9jPc9r7Wj0n8xRqduiryyHo2I/pDBLsHCNFwdTSxaniouLAvTqrXrzcsjVDQS2z/St/ lyZw== 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; bh=VEMae1Egg7e/TQrqudat7RWfq1maLIQTVwhxb3s1OeM=; b=MnngTIfAGDiFPaXRa87SQOld9p5BxuYu/jgY051jeIqCS/gzSDL5FgRRx75epJKpP6 /Dv6ws7rWAAeJzqDvP/wTzwaeaYmN58ei/AM6HEx2vgs5hWtq1bllbmBPuAwRpvoOaNe k0Z4CHfrwZ9DH22H1EgLl80WhCJQBAusfIR/bD9Py+PXvQbt5ZjK4H1UmTiuSzCnc6A8 niYhf6d8Tlkmaqa1hUJ1N4SLLjksc+IcBouutYNcSAfn4w5xiWVr5EstB97A841TSRuW TABd8QpQhIB6klE7KufdnvV1gGZbm9fK5AKGpNac+Xc++GojS+5pkXXyZnzhpeiMHlWB C23A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si6292140ejd.57.2020.05.18.05.55.13; Mon, 18 May 2020 05:55:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727036AbgERMx3 (ORCPT + 99 others); Mon, 18 May 2020 08:53:29 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59920 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbgERMx3 (ORCPT ); Mon, 18 May 2020 08:53:29 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jafGo-0005Y1-9c; Mon, 18 May 2020 12:53:26 +0000 Date: Mon, 18 May 2020 14:53:25 +0200 From: Christian Brauner To: Tycho Andersen Cc: Aleksa Sarai , Kees Cook , linux-api@vger.kernel.org, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] seccomp: Add group_leader pid to seccomp_notif Message-ID: <20200518125325.l2lpixp3ch7zuiwx@wittgenstein> References: <20200515234005.32370-1-sargun@sargun.me> <202005162344.74A02C2D@keescook> <20200517104701.bbn2d2rqaplwchdw@wittgenstein> <20200517112156.cphs2h33hx2wfcs4@yavin.dot.cyphar.com> <20200517142316.GA1996744@cisco> <20200517143311.fmxaf3pnopuaezl4@wittgenstein> <20200517144603.GD1996744@cisco> <20200517150215.GE1996744@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200517150215.GE1996744@cisco> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 17, 2020 at 09:02:15AM -0600, Tycho Andersen wrote: > On Sun, May 17, 2020 at 08:46:03AM -0600, Tycho Andersen wrote: > > On Sun, May 17, 2020 at 04:33:11PM +0200, Christian Brauner wrote: > > > struct seccomp_notif2 { > > > __u32 notif_size; > > > __u64 id; > > > __u32 pid; > > > __u32 flags; > > > struct seccomp_data data; > > > __u32 data_size; > > > }; > > > > I guess you need to put data_size before data, otherwise old userspace > > with a smaller struct seccomp_data will look in the wrong place. > > > > But yes, that'll work if you put two sizes in, which is probably > > reasonable since we're talking about two structs. > > Well, no, it doesn't either. Suppose we add a new field first to > struct seccomp_notif2: > > struct seccomp_notif2 { > __u32 notif_size; > __u64 id; > __u32 pid; > __u32 flags; > struct seccomp_data data; > __u32 data_size; > __u32 new_field; > }; > > And next we add a new field to struct secccomp_data. When a userspace > compiled with just the new seccomp_notif2 field does: > > seccomp_notif2.new_field = ...; > > the compiler will put it in the wrong place for the kernel with the > new seccomp_data field too. > > Sort of feels like we should do: > > struct seccomp_notif2 { > struct seccomp_notif *notif; > struct seccomp_data *data; > }; > > ? Oh yes of course, sorry that was my stupid typo. I meant: struct seccomp_notif2 { __u32 notif_size; __u64 id; __u32 pid; __u32 flags; struct seccomp_data *data; __u32 data_size; __u32 new_field; } at which point things should just work imho. This is similar to how the set_tid array works. The kernel doesn't need to allocate any more too. The kernel can just always use the currently know seccomp_data size. If the kernel supports _less_ than what the caller expects, it can report the supported size in data_size to userspace returning EINVAL. If it supports more then it can just copy the known fields, I guess. This way we don't need to add yet another ioctl... Christian