Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2442196ybl; Thu, 9 Jan 2020 12:51:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzee5pFjsm7mbz4IbytmnHzwwLu99wdw+C92L0kfDH6ApJgz7QcdE2oX6FjVNBwStAsy1pq X-Received: by 2002:a05:6830:1292:: with SMTP id z18mr10179795otp.148.1578603092257; Thu, 09 Jan 2020 12:51:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578603092; cv=none; d=google.com; s=arc-20160816; b=nN9LgyWe+nE1kG73TUIZ6CZFe3gMyVZ2GrYI9u1rSbAgqi7RTnufNrUGRL5ztIOeAO qguJbpl5EfRMQ2w4OIyCkF82z49uvVhuQP4HoI/gaNb5mJvOi5K5OovR2Ouyu9ZTbQKz 4J0pl6U1U87ovOc3DOqfIIi1+PdJxquYc5J0yxXbKjpBLD9YFEUU/b9avTDc2Xj1HtgJ +Qahth5LPxsGxKke+wmIBPuqsWbTgM1qt87WlAyTPBhkJxxJpKfWE3/F9s72KBSyCRfy WQiXuvMKDyKjT6N2k88x5ob6884fg44zK+h3kNvLZAjmpBrO19hG2TO7vOl2ukYwmzCH DfEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=Jw28hdiJGOkCKx6DV/ZAWWtrssY8Hn/bW9QkvV8cGmI=; b=KhUkdPp9l6d7/lrx7FXqMxOjpqZp5rmd1DZYca8GemFwRKXfJWbIput1SVxUZwOB4f ejr3iHlkzVtX+N9UAMMvnQU8ngQte5uo2CatVt2o9WRI4isnOFfpWl3+KUTzUzVeP/3P VoC3SmJs9N4TRglT+I7rL/zq4e1T3BSdshg/LmsVFvnwkkREL0mCLcslJGrM/3HItuCv GsRCpnEBtR6pMgKlb/53ENtIhhEYO+y4H2rgBp3i3Mgq7igRJYaWLjM1HEnJVfDx73xO tC8yvHd1QrflbdzwcmvmIef6CMBajkZYHYrH+WUGCWqYhdI7sBwvBXO2MCeKd9H009nW BzkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gq6zgGEY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si4214497oia.236.2020.01.09.12.51.21; Thu, 09 Jan 2020 12:51:32 -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=@chromium.org header.s=google header.b=gq6zgGEY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731704AbgAITnH (ORCPT + 99 others); Thu, 9 Jan 2020 14:43:07 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:40997 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731574AbgAITnH (ORCPT ); Thu, 9 Jan 2020 14:43:07 -0500 Received: by mail-wr1-f65.google.com with SMTP id c9so8682414wrw.8 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=ejjUEHr2VGLuB9Lzy6gTd1fmyNIcjBVEIZJ282q69rHiFGYTjYGYvw+DRKtiyTU05F 40sODzv36Ko5tc3Eiu/rv1aJ5yiUD6zVH34ZYrbx7z000XWynNAx2S3qANfl1fCJMZFc XYdsK5sR+Le07xVNmN5Cc3hPDyqQRkqQYofCnDYiQNuyYr2HSltoG1l96RDfdyXeE9eO mb4Bc/hqlukk1eoybyU3mCcVGPuP4pZNz2jO+BllONA1oLccewVNtt+KuSwkqedXpsQ+ 0CB5QcI7vgRz0dboTI3ORMGDLHFT8N+5mFpkXTqS04Y3Qs2eO9Ldh7woWQkon0A4Tm4h M5pQ== X-Gm-Message-State: APjAAAWMsi9WM4/G0KYCDq/dIisy+u5aL+8QzPN9OEzMC+hSvNA9MJR6 RMxGrUKYqf4LnvQa+v9O+Ob4Nw== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 > >