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 E679EC43331 for ; Fri, 27 Mar 2020 14:29:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9DEB206F2 for ; Fri, 27 Mar 2020 14:29:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HvKrQXl6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727620AbgC0O3y (ORCPT ); Fri, 27 Mar 2020 10:29:54 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37648 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727335AbgC0O3y (ORCPT ); Fri, 27 Mar 2020 10:29:54 -0400 Received: by mail-wr1-f65.google.com with SMTP id w10so11688877wrm.4 for ; Fri, 27 Mar 2020 07:29:51 -0700 (PDT) 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:content-transfer-encoding:in-reply-to :user-agent; bh=7Zt6SLl1aTUxOOXGO0w2ygq6jqSkCyYzZ2HwaOn8m8A=; b=HvKrQXl6CnavrASXBIW6eNLJ0pJ/BUDaqpuU3EBwzRfnU5o76D8VAhzATHdkU41xAG fHvPOl0JHylpN138JC+O+5jQ4Odx8B95X6poKn732ENl1afDY6bt1Giguv37ox+n7qNg vBmt30/94c4E//F3K0wXfQQxV65O93+DoQJtY= 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:content-transfer-encoding :in-reply-to:user-agent; bh=7Zt6SLl1aTUxOOXGO0w2ygq6jqSkCyYzZ2HwaOn8m8A=; b=DHgqbHH3AHEBv+hVmzQgDP2CWsld6S22leY0EmYAAe4ACGpoV9wq4CkfGi6WVzmWCW aaqdFXhephfCqKNah+OX7IvpCzp+wREKo5kD/BJ6eNka9B2k/AyGUuv8vqVA0wmzF2Vf LcYHyWlM4qaJOQWOPlRgiyhmDipVsUqWdMmBRIufq7YulVU4D878O+sEhtODULExr4UL +tk7KOb0v2Wk8+jio5FhErBr3VH2YFViEes+HMv7Z7zvpdXKDlM1EED2pU9NoeV/NRAY gdr9mUYxf8jHtuu1frNSXhj+ifzJtQZIWc54J3o6vPgd4pqn4K8fO0CP96Sn8sauJHXc VOXw== X-Gm-Message-State: ANhLgQ0dy2Av/o+ghvncTKJxhxQUGaIy3DhzvnH4iUBjUBqaugXHCXOP 8mzSPaHPaX17KRyeT8jdIb/kuQ== X-Google-Smtp-Source: ADFU+vtMVikTi8+QZsr8Smgd86ygktQImaDCLFpPwBryY7M3+OoqCtEIQj/OE5rvLyrjg6rHvmiCQg== X-Received: by 2002:adf:a1d6:: with SMTP id v22mr15712097wrv.416.1585319390652; Fri, 27 Mar 2020 07:29:50 -0700 (PDT) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id v8sm8867894wrp.84.2020.03.27.07.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2020 07:29:50 -0700 (PDT) From: KP Singh X-Google-Original-From: KP Singh Date: Fri, 27 Mar 2020 15:29:43 +0100 To: Stephen Smalley Cc: James Morris , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, Brendan Jackman , Florent Revest , Alexei Starovoitov , Daniel Borkmann , Kees Cook , Paul Turner , Jann Horn , Florent Revest , Brendan Jackman , Greg Kroah-Hartman , Paul Moore Subject: Re: [PATCH bpf-next v7 4/8] bpf: lsm: Implement attach, detach and execution Message-ID: <20200327142943.GA23618@chromium.org> References: <20200326142823.26277-1-kpsingh@chromium.org> <20200326142823.26277-5-kpsingh@chromium.org> <2241c806-65c9-68f5-f822-9a245ecf7ba0@tycho.nsa.gov> <20200327124115.GA8318@chromium.org> <14ff822f-3ca5-7ebb-3df6-dd02249169d2@tycho.nsa.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14ff822f-3ca5-7ebb-3df6-dd02249169d2@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 27-Mär 09:43, Stephen Smalley wrote: > On 3/27/20 8:41 AM, KP Singh wrote: > > On 27-Mär 08:27, Stephen Smalley wrote: > > > On 3/26/20 8:24 PM, James Morris wrote: > > > > On Thu, 26 Mar 2020, KP Singh wrote: > > > > > > > > > +int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog, > > > > > + const struct bpf_prog *prog) > > > > > +{ > > > > > + /* Only CAP_MAC_ADMIN users are allowed to make changes to LSM hooks > > > > > + */ > > > > > + if (!capable(CAP_MAC_ADMIN)) > > > > > + return -EPERM; > > > > > + > > > > > > > > Stephen, can you confirm that your concerns around this are resolved > > > > (IIRC, by SELinux implementing a bpf_prog callback) ? > > > > > > I guess the only residual concern I have is that CAP_MAC_ADMIN means > > > something different to SELinux (ability to get/set file security contexts > > > unknown to the currently loaded policy), so leaving the CAP_MAC_ADMIN check > > > here (versus calling a new security hook here and checking CAP_MAC_ADMIN in > > > the implementation of that hook for the modules that want that) conflates > > > two very different things. Prior to this patch, there are no users of > > > CAP_MAC_ADMIN outside of individual security modules; it is only checked in > > > module-specific logic within apparmor, safesetid, selinux, and smack, so the > > > meaning was module-specific. > > > > As we had discussed, We do have a security hook as well: > > > > https://lore.kernel.org/bpf/20200324180652.GA11855@chromium.org/ > > > > The bpf_prog hook which can check for BPF_PROG_TYPE_LSM and implement > > module specific logic for LSM programs. I thougt that was okay? > > > > Kees was in favor of keeping the CAP_MAC_ADMIN check here: > > > > https://lore.kernel.org/bpf/202003241133.16C02BE5B@keescook > > > > If you feel strongly and Kees agrees, we can remove the CAP_MAC_ADMIN > > check here, but given that we already have a security hook that meets > > the requirements, we probably don't need another one. > > I would favor removing the CAP_MAC_ADMIN check here, and implementing it in Okay. For the scope of this series I will remove this check in the next revision. If people feel strongly that we need it centrally within the BPF infrastructure, we can do that as a separate patch and discuss it there. > a bpf_prog hook for Smack and AppArmor if they want that. SELinux would > implement its own check in its existing bpf_prog hook. I think Smack and AppArmor can also use the same hook. Since we already have a hook, I don't think anyone is blocked from implementing policy logic for loading LSM BPF programs. James/Kees does this sound okay? - KP > > >