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=-2.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 277E0C33CA1 for ; Thu, 9 Jan 2020 19:11:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E12592077C for ; Thu, 9 Jan 2020 19:11:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DhUG7DVS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388682AbgAITLg (ORCPT ); Thu, 9 Jan 2020 14:11:36 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36393 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732322AbgAITLf (ORCPT ); Thu, 9 Jan 2020 14:11:35 -0500 Received: by mail-wr1-f67.google.com with SMTP id z3so8619999wru.3 for ; Thu, 09 Jan 2020 11:11:33 -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=VCnERlNOb8YhgeYQ/pqHHRSiRgRe3Wo0NvX3JaaKcS8=; b=DhUG7DVSwPgwTWwTuQqa+9ac/15/zkq8KDq1LyXt9P2r/hB4jgPF/wdkpAwwitW1w/ Yw1ncdxhj1h1xmR3bnTVGYgx9vqeZ9TOp8Q5YfaeApe9I12PJZzgFMURzpY+OPgI15a4 Fexvw8F5wcZmKpTYiVdv+PZVy/+Kym+/wM6Mo= 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=VCnERlNOb8YhgeYQ/pqHHRSiRgRe3Wo0NvX3JaaKcS8=; b=syg72eMZ+BoZVkU9sY/uRwRIOKpP5fKYkjlqMnQ/IdAGmOBokx8s1lONvM9A/iaA4q U1rI0cIb1SbQAQlUDcGqwVKiQAaSkNDBWbe0BozC9klxEyW1gBGSty/MivUaRGKMBgWt Mfj6HcxcZRlej9uAYdtxloZGx3e5uTS96bhDmYUjtWSXIQJuV+hyT7BWVsvXyAoHEuDL Eev13Pgp3pqitVU9Fp3H8/hBb5mIX5BAZvqRlhR23cY5EcWH6tT341k9GT376MaefjVB 0XN86ueQm6VLQxCIQHXv4q+DC11gjOMRogWgcRbCgp/+A/ydOaPJXyr6EvteKyCsNpNC A+Pw== X-Gm-Message-State: APjAAAWAXkioqJaFruerpI2+2Kg4CcvIDTA8suMR7DI5hxtMG6Xx/rKP Tff3+QgdHsOGm/DGUtgC4ucYhQ== X-Google-Smtp-Source: APXvYqxxWo37fIJf5Xfz49p7PCsn9MSEishKBdsp6/eF79xvuIAU/pnDyQmSV2/kSQfLuhQi+KsjjQ== X-Received: by 2002:adf:f5cb:: with SMTP id k11mr11962302wrp.71.1578597092527; Thu, 09 Jan 2020 11:11:32 -0800 (PST) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id q3sm3689862wmc.47.2020.01.09.11.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 11:11:31 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Thu, 9 Jan 2020 20:11:48 +0100 To: James Morris Cc: Stephen Smalley , 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: <20200109191148.GA1894@chromium.org> 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: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On 10-Jan 05:11, 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. > > This would be similar to the difference between iptables rules and > loadable eBPF networking code. I'd be interested to know how the > eBPF networking scenarios are handled wrt kernel ABI. > > > > Again, not arguing for or against, but wondering if people fully understand > > the implications. If it ends up being useful, people will build access > > control systems with it, and it directly exposes a lot of kernel internals to > > userspace. There was a lot of concern originally about the LSM hook interface > > becoming a stable ABI and/or about it being misused. Exposing that interface > > along with every kernel data structure exposed through it to userspace seems > > like a major leap. > > Agreed this is a leap, although I'm not sure I'd characterize it as > exposure to userspace -- it allows dynamic extension of the LSM API from > userland, but the code is executed in the kernel. > > KP: One thing I'd like to understand better is the attack surface > introduced by this. IIUC, the BTF fields are read only, so the eBPF code > should not be able to modify any LSM parameters, correct? > That's correct, the verifier does not allow writes to BTF types: from kernel/bpf/verifier.c: case PTR_TO_BTF_ID: if (type == BPF_WRITE) { verbose(env, "Writes through BTF pointers are not allowed\n"); return -EINVAL; } We can also add additional checks on top of those added by the verifier using the verifier_ops that each BPF program type can define. - KP > > > Even if the mainline kernel doesn't worry about any kind > > of stable interface guarantees for it, the distros might be forced to provide > > some kABI guarantees for it to appease ISVs and users... > > How is this handled currently for other eBPF use-cases? > > -- > James Morris > >