Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2596287ybx; Fri, 8 Nov 2019 06:38:15 -0800 (PST) X-Google-Smtp-Source: APXvYqx2PPFGynSUgqBffPWRaPtHkVMNvnG5KA9AyhhoAckRPcVNBC/yQrVXUIpvofBlBoPHPH6z X-Received: by 2002:a17:906:5397:: with SMTP id g23mr8727710ejo.93.1573223894854; Fri, 08 Nov 2019 06:38:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573223894; cv=none; d=google.com; s=arc-20160816; b=y8VUYid9FyY5Q2d5G92/I3SfJaMWyvo2wT0V4+iGmOhvyRQ8CmD2QtUM/InzUH3Qca x7GmyRjT9dAas661dIrCY16uXiBsXMBfCjcP+LfLLs1Rkj4RBix9q0S+65IZ64UABLQC q3dfYY7LSfrraRTzTGYBlwS1WdhoT8gJV7DQZBG2XDXN95bFtK2lBhWrV6WR1Pd7Xpau LGMJ0/rzd8bWtDV44HVWw4ebpuPictqiSIjdYAEfIGu++YqZ27i2v6qwuQlEcE3i7NI2 XcAN6UhGWjRbt+1cZA2cWNdF1CdmJfbx+4MvUDO3jqj8XpYYPvnOiGuOv4x1DjbDblxZ B3lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=fxfHECUtDyty8TvMRaLY2jxwWyZ79yYsmDjmuiIg27U=; b=1LXXgnEcbph86bYBQtMAaUGLG1ymqwn++z1PX5TRxxv1TCtTAROmgE51vGuQfQJ9jZ WsbUVYnqdNjMsBZVaBx7J7gAPjdkmmgNXR4adz5jxx3NCdejWzLJJ+jty0V/pEUY/O9I /Feiy7guuYb+JUfOkYb+GwB+weBOpcZ4VhZS8F+uP6dq23dG7oXF7YPQpjIvfXvtk0jB RdYaYq7fpfkjwpzm1xfpAxAXLheaTOVBOMm4uP3r5zd/fSI92cseEHtOXvnNltqY3Gjv m/jFWF7IkNs5J30AQaqkoJQ/nAv8wvjy9uKPH9HMrxwTODupey18vnrcvEW04ntVEgGh sc0Q== 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 a24si4569105eda.446.2019.11.08.06.37.51; Fri, 08 Nov 2019 06:38:14 -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 S1727148AbfKHOfG (ORCPT + 99 others); Fri, 8 Nov 2019 09:35:06 -0500 Received: from www62.your-server.de ([213.133.104.62]:40894 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbfKHOfG (ORCPT ); Fri, 8 Nov 2019 09:35:06 -0500 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1iT5Lo-0001VR-E6; Fri, 08 Nov 2019 15:35:00 +0100 Received: from [2a02:1205:507e:bf80:bef8:7f66:49c8:72e5] (helo=pc-11.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1iT5Ln-000Uz8-JS; Fri, 08 Nov 2019 15:34:59 +0100 Subject: Re: [PATCH bpf-next v13 4/7] landlock: Add ptrace LSM hooks To: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , KP Singh Cc: Alexei Starovoitov , linux-kernel@vger.kernel.org, Alexei Starovoitov , Andy Lutomirski , Casey Schaufler , David Drysdale , Florent Revest , James Morris , Jann Horn , John Johansen , Jonathan Corbet , Kees Cook , Michael Kerrisk , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= , Paul Moore , Sargun Dhillon , "Serge E . Hallyn" , Shuah Khan , Stephen Smalley , Tejun Heo , Tetsuo Handa , Tycho Andersen , Will Drewry , bpf@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org References: <20191104172146.30797-1-mic@digikod.net> <20191104172146.30797-5-mic@digikod.net> <20191105171824.dfve44gjiftpnvy7@ast-mbp.dhcp.thefacebook.com> <23acf523-dbc4-855b-ca49-2bbfa5e7117e@digikod.net> <20191105193446.s4pswwwhrmgk6hcx@ast-mbp.dhcp.thefacebook.com> <20191106100655.GA18815@chromium.org> <813cedde-8ed7-2d3b-883d-909efa978d41@digikod.net> <20191106214526.GA22244@chromium.org> <3e208632-e7ab-3405-5196-ab1d770e20c3@digikod.net> From: Daniel Borkmann Message-ID: <5d0f1dc5-5a99-bd6a-4acc-0cdcd062a0c9@iogearbox.net> Date: Fri, 8 Nov 2019 15:34:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <3e208632-e7ab-3405-5196-ab1d770e20c3@digikod.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.101.4/25627/Fri Nov 8 11:02:39 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/8/19 3:08 PM, Mickaël Salaün wrote: > On 06/11/2019 22:45, KP Singh wrote: >> On 06-Nov 17:55, Mickaël Salaün wrote: >>> On 06/11/2019 11:06, KP Singh wrote: >>>> On 05-Nov 11:34, Alexei Starovoitov wrote: >>>>> On Tue, Nov 05, 2019 at 07:01:41PM +0100, Mickaël Salaün wrote: >>>>>> On 05/11/2019 18:18, Alexei Starovoitov wrote: [...] >> * Use a single BPF program type; this is necessary for a key requirement >> of KRSI, i.e. runtime instrumentation. The upcoming prototype should >> illustrate how this works for KRSI - note that it’s possible to vary >> the context types exposed by different hooks. > > Why a single BPF program type? Do you mean *attach* types? Landlock only > use one program type, but will use multiple attach types. > > Why do you think it is necessary for KRSI or for runtime instrumentation? > > If it is justified, it could be a dedicated program attach type (e.g. > BPF_LANDLOCK_INTROSPECTION). > > What is the advantage to have the possibility to vary the context types > over dedicated *typed* contexts? I don't see any advantages, but at > least one main drawback: to require runtime checks (when helpers use > this generic context) instead of load time checks (thanks to static type > checking of the context). Lets take security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) as one specific example here: the running kernel has its own internal btf_vmlinux and therefore a complete description of itself. From verifier side we can retrieve & introspect the security_sock_rcv_skb signatue and thus know that the given BPF attachment point has struct sock and struct sk_buff as input arguments which can then be accessed generically by the prog in order to allow sk_filter_trim_cap() to pass or to drop the skb. The same generic approach can be done for many of the other lsm hooks, so single program type would be enough there and context is derived automatically, no dedicated extra context per attach type would be needed and no runtime checks as you mentioned above since its still all asserted at verification time. Thanks, Daniel