Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2540149ybb; Fri, 27 Mar 2020 07:31:10 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu58Bsm0qHrEvi20zbuFnWtgbP/5JiSUbMdlPRE1nK9um4Nj+cSMG0e8ZX3hYQ/DY1k5PbK X-Received: by 2002:aca:4ecc:: with SMTP id c195mr3899516oib.123.1585319469989; Fri, 27 Mar 2020 07:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585319469; cv=none; d=google.com; s=arc-20160816; b=Z35sWXazn78o7cRapC6tc6661oUjd6g6kFpZqsjdHsSJN9e9QUxoAEfc/fSALJp8y1 cqtw9y0NPnPDBucHrEJ9NYYFEWyONlvAXyosZ6y8KMQQnAOuvVbXmA7leM4b46/7xgY1 khRdqIjXBuxAmaQZ/ro+Nw41YA+6x2C8+OyTRGx+o7dNUC0+gFa0bislTxRGr53fgi2m bIm0AGPTRRcFmpWgLhojAySRCDxTl6IYNKFl5UnSFckNmxZAd0VbN428KGvzbI3tNHrY l58E3PGUZ2meI49ntd+ki9kAM+QKG4ZmWX6MGJ0WsHA4qTp1FdmC72Oo9LrducdkNYjI s4wA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=7Zt6SLl1aTUxOOXGO0w2ygq6jqSkCyYzZ2HwaOn8m8A=; b=OtXt8F7nFHoa8rmKZR+lDXWMNXxj8URDRrffV+TfozzMW6WhCAqFyS0jIlFWoxc89k AttSvZTAo1eT4OihJv88Y1ABYPDeRgMlLAzUj1M8HECOXmHTR4jl6XBKjKN4h/44pyj4 Ke5B3YeS0sk4vC8udymDWwLJoy7WQGZSoZwi4EBnz5PWGfbVyynyx9nzXJGpw/ToHNSm rSjgs0xk1rsJFYZvc3nS0EkXlPz1gDl+NfC3YlIkTUmbCoNT0FCyi3gB5yNYerpKrp7z EVCzmm/XhnlZ+NVKluWKQFKHJ7fX6MFn20uH6kMS/9eYiuml+XSJZLtFejrE8g3j7IZk S4wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HvKrQXl6; 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 i4si2379268oii.211.2020.03.27.07.30.52; Fri, 27 Mar 2020 07:31:09 -0700 (PDT) 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=HvKrQXl6; 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 S1727575AbgC0O3y (ORCPT + 99 others); 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-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 > > >