From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05FD5C33CA1 for ; Thu, 9 Jan 2020 19:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDBD12072E for ; Thu, 9 Jan 2020 19:43:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gq6zgGEY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731639AbgAITnJ (ORCPT ); Thu, 9 Jan 2020 14:43:09 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43585 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbgAITnI (ORCPT ); Thu, 9 Jan 2020 14:43:08 -0500 Received: by mail-wr1-f67.google.com with SMTP id d16so8648647wre.10 for ; Thu, 09 Jan 2020 11:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Jw28hdiJGOkCKx6DV/ZAWWtrssY8Hn/bW9QkvV8cGmI=; b=gq6zgGEYKGXFXM2EbpaV389P3IoxQr30Jnhm7/E2wfq734f+k9jU5i9vJZ/c5z4chQ pYXGDucfiGxafkwpCKXAQE9nFdGnpwkCYNwTt/AdJztjucF1TrS9VYHOScqW32D6Kw13 GQWuzD0jelFWxHO2SpYpdOF1JOr2mhNRiWHmw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Jw28hdiJGOkCKx6DV/ZAWWtrssY8Hn/bW9QkvV8cGmI=; b=nejMxG58xQ1WooWwgmt/lliZi5lKBM/vhkAWy1uva/minGF3pJ3hcSmNyC/qWrPrHB L4Ov0tATKTu7l+u3mxiyFTMHUhkaRJIeKNgDORois3E7b11HvVaTT9+4BQC25dQLvYhA +bFHX5BEb/d3CgxoC7O6XKTF/Wuyzqgtm13HF3YYrXkejKXb1Thi7vkfbEzGoAaPQY1t aJm6UHUFjhHaBAtpHFfg6s+n+3DZtMH7pqlsl8Wi3JB+GuOeuGaaeugvh9klx/OQmzV4 Mdbcj6dRgSDN2TprCczmVc/SbGcdR2AMa/T3iROc1mXJ6oaGtf3dEKEEV/H5p9JTh+A/ yy4A== X-Gm-Message-State: APjAAAV9P1IgATNcoFuGbhzvocCU2uiX7Gt4VM+A8NBHdKYEtiCH+oaA 7aWJcqxTxO6AW2/oeOBhSistZQ== X-Google-Smtp-Source: APXvYqxFrV0L2j8O/4RTuF6OYfIwcvV94yuOK6Qd6u8NVLbIqTCAF73WthoWgSDFZkahivXdF2VM/g== X-Received: by 2002:a5d:4687:: with SMTP id u7mr12573335wrq.176.1578598985376; Thu, 09 Jan 2020 11:43:05 -0800 (PST) Received: from google.com ([2a00:79e0:42:204:8a21:ba0c:bb42:75ec]) by smtp.gmail.com with ESMTPSA id r62sm4071750wma.32.2020.01.09.11.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 11:43:04 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Thu, 9 Jan 2020 20:43:02 +0100 To: James Morris Cc: Stephen Smalley , Kees Cook , KP Singh , Casey Schaufler , open list , bpf , linux-security-module@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Thomas Garnier , Michael Halcrow , Paul Turner , Brendan Gregg , Jann Horn , Matthew Garrett , Christian Brauner , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Florent Revest , Brendan Jackman , Martin KaFai Lau , Song Liu , Yonghong Song , "Serge E. Hallyn" , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Nicolas Ferre , Stanislav Fomichev , Quentin Monnet , Andrey Ignatov , Joe Stringer , Paul Moore Subject: Re: [PATCH bpf-next v1 00/13] MAC and Audit policy using eBPF (KRSI) Message-ID: <20200109194302.GA85350@google.com> References: <20191220154208.15895-1-kpsingh@chromium.org> <95036040-6b1c-116c-bd6b-684f00174b4f@schaufler-ca.com> <201912301112.A1A63A4@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 10-Jan 06:07, James Morris wrote: > On Thu, 9 Jan 2020, Stephen Smalley wrote: > > > On 1/9/20 1:11 PM, James Morris wrote: > > > On Wed, 8 Jan 2020, Stephen Smalley wrote: > > > > > > > The cover letter subject line and the Kconfig help text refer to it as a > > > > BPF-based "MAC and Audit policy". It has an enforce config option that > > > > enables the bpf programs to deny access, providing access control. IIRC, > > > > in > > > > the earlier discussion threads, the BPF maintainers suggested that Smack > > > > and > > > > other LSMs could be entirely re-implemented via it in the future, and that > > > > such an implementation would be more optimal. > > > > > > In this case, the eBPF code is similar to a kernel module, rather than a > > > loadable policy file. It's a loadable mechanism, rather than a policy, in > > > my view. > > > > I thought you frowned on dynamically loadable LSMs for both security and > > correctness reasons? Based on the feedback from the lists we've updated the design for v2. In v2, LSM hook callbacks are allocated dynamically using BPF trampolines, appended to a separate security_hook_heads and run only after the statically allocated hooks. The security_hook_heads for all the other LSMs (SELinux, AppArmor etc) still remains __lsm_ro_after_init and cannot be modified. We are still working on v2 (not ready for review yet) but the general idea can be seen here: https://github.com/sinkap/linux-krsi/blob/patch/v1/trampoline_prototype/security/bpf/lsm.c > > Evaluating the security impact of this is the next step. My understanding > is that eBPF via BTF is constrained to read only access to hook > parameters, and that its behavior would be entirely restrictive. > > I'd like to understand the security impact more fully, though. Can the > eBPF code make arbitrary writes to the kernel, or read anything other than > the correctly bounded LSM hook parameters? > As mentioned, the BPF verifier does not allow writes to BTF types. > > And a traditional security module would necessarily fall > > under GPL; is the eBPF code required to be likewise? If not, KRSI is a > > gateway for proprietary LSMs... > > Right, we do not want this to be a GPL bypass. This is not intended to be a GPL bypass and the BPF verifier checks for license compatibility of the loaded program with GPL. - KP > > If these issues can be resolved, this may be a "safe" way to support > loadable LSM applications. > > Again, I'd be interested in knowing how this is is handled in the > networking stack (keeping in mind that LSM is a much more invasive API, > and may not be directly comparable). > > -- > James Morris > >