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=ham 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 36163C282DD for ; Fri, 10 Jan 2020 15:28:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2E572072E for ; Fri, 10 Jan 2020 15:28:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="F33T91L+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbgAJP2D (ORCPT ); Fri, 10 Jan 2020 10:28:03 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37436 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbgAJP2C (ORCPT ); Fri, 10 Jan 2020 10:28:02 -0500 Received: by mail-wm1-f65.google.com with SMTP id f129so2401646wmf.2 for ; Fri, 10 Jan 2020 07:28:01 -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=aXkYk1wr3xOcC4kmVHKlnMGgZqSHONG6or7V3cMRBfw=; b=F33T91L+0exJkm4W6ymnTYAWlH6C8rI++wYC55+vSK+32TVCw3utrIIHPL9gWWuR4z Ooq0VqOPl3V1PZOQCVH3wmxk0C3bUiD8MhUezkehT3gFsnucpt/tuSILyO27GZyOpdZV xb0Y2RP5w4A8Lh7Rvv8nzlGJNO4J12Pj6NZ+Y= 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=aXkYk1wr3xOcC4kmVHKlnMGgZqSHONG6or7V3cMRBfw=; b=XZJiE5xrbKfHk/kBFoZJZqzn+33fJsKlup9Iy63xfx1TgkbF5Z/+iKCyyP9isOeZjx NQTjHGcF5gng7EY6XmkekKRA76c+bkkM3kDkZe5OnVu7JQ1NEaYm7sPbhS0RWuXnSaWS 4kBQ+c7zK/9zu3WWkpK+BTRGqVNq7KjTC8tHc+RdmW7XB7ovCtpUIsCBLxc87vwvG5IX oTZ5AXtyy3897p0Hbv9q7oUrJ87dP91Sn5dbTEsUmnJuLP4sKfWTbTRXbatiNCo4W18U 4VNs2CwUIUI702SCzFEOCQtDMvw0INxkco/4HTJZI8NRYPISG1I9Xg6SlLGRsbG2adKf VHgg== X-Gm-Message-State: APjAAAVeR/N1BOjTbTCfpEGl50iUVUoEs8n7i2/LCLBJtKHRT9yB7CpA agX83ke/Tq6lt1jjjQXqkaEJlQ== X-Google-Smtp-Source: APXvYqw0ag02q22hPKuOzI3/vkzH86GFjij0AS1uLwSH4KQPjjBom3rLw/8TFnXp5EIU2M4mQ97Qxw== X-Received: by 2002:a1c:541b:: with SMTP id i27mr5205966wmb.137.1578670081018; Fri, 10 Jan 2020 07:28:01 -0800 (PST) Received: from google.com ([2a00:79e0:42:204:8a21:ba0c:bb42:75ec]) by smtp.gmail.com with ESMTPSA id f1sm2560213wro.85.2020.01.10.07.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2020 07:28:00 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Fri, 10 Jan 2020 16:27:58 +0100 To: Stephen Smalley Cc: KP Singh , James Morris , Kees Cook , 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: <20200110152758.GA260168@google.com> References: <201912301112.A1A63A4@keescook> <20200109194302.GA85350@google.com> <8e035f4d-5120-de6a-7ac8-a35841a92b8a@tycho.nsa.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8e035f4d-5120-de6a-7ac8-a35841a92b8a@tycho.nsa.gov> 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 09-Jan 14:47, Stephen Smalley wrote: > On 1/9/20 2:43 PM, KP Singh wrote: > > 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. > > IIUC, it checks that the program is GPL compatible if it uses a function > marked GPL-only. But what specifically is marked GPL-only that is required > for eBPF programs using KRSI? Good point! If no-one objects, I can add it to the BPF_PROG_TYPE_LSM specific verification for the v2 of the patch-set which would require all BPF-LSM programs to be GPL. - KP > > > > > - 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 > > > > > > >