Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4153158iog; Tue, 28 Jun 2022 10:03:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slWZsZsdWRqjA33OVcuStRz8CVY+WsdHQo/+ss0TV2PRz4cFRsTBxCsbOR9LmBRe10nvOv X-Received: by 2002:a63:4c07:0:b0:40d:8b81:5638 with SMTP id z7-20020a634c07000000b0040d8b815638mr18210396pga.449.1656435827353; Tue, 28 Jun 2022 10:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656435827; cv=none; d=google.com; s=arc-20160816; b=xWHARZZs49GXesHQr8brlItZKui7iLgQ0qDUcsUHv+TQe59Vzgv3PodKMJfjvDWv7s HhgAetgWXowF8Rwq2tmxvzm5MYySgOm+5cCOhlVllVKEltSB+47aYBSMsyotdZiN1hrz ZhPUruNa6Ue7dhtmWMP+lWMM9hAfSeFDsDNptN3BKyvJWZxMQguio9D3ROns1NLL4Gp+ LD3sY9qN6ymgozb4sYJcBi/T/xevlfYCoUugYfMXqtFue/cjw7L5Ogp95L18WSk5klG7 rNJLfZ6aaenjd5mhfS1bubbLJEbcMT+6sdtERJ9gD0FnmGF7AOlmEegGWJHevefu2Azn YEsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :reply-to:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=vJfBn+f7lVK7AifdRhZ14mIHvBk5ROqtbtEkpEUekVI=; b=X4y4SC4NHuXXlSWI2hX8NuGAXgnKVPJn9hVU0/XvpOlWpV2Lln9KDXQsueYb18pAc9 T4Oc5KO6YiJqRKa1QaWHWESGRoKm7enxyBPBnYB+UIYI2StdEbKmL9NQcgiLK9YU4HWR nanK8yfseC/BFWyg8zyrf0Ff7NzXV7Bo7kulfzVtdkqQAcjqPWln8zY73i9QalMCusgd Kvsm4WgUQUfdjSKTPyBaDiXZrL4FENYrSPhi7LBbKbysrCiW1eMw2PPwplKCfATCaqCd 2w51nBIyp8DG22QgrDVeSCKb+JybQTPisjYSzq8x55sdD7wXeNg+jlh3IEVySZyq8+rb 0/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=PStwN8J9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik18-20020a170902ab1200b0016a080b3988si20894461plb.130.2022.06.28.10.03.10; Tue, 28 Jun 2022 10:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=PStwN8J9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229979AbiF1QuQ (ORCPT + 99 others); Tue, 28 Jun 2022 12:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237642AbiF1Qrq (ORCPT ); Tue, 28 Jun 2022 12:47:46 -0400 Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4561C286D7 for ; Tue, 28 Jun 2022 09:44:50 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1048b8a38bbso17748819fac.12 for ; Tue, 28 Jun 2022 09:44:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:reply-to:from:in-reply-to:content-transfer-encoding; bh=vJfBn+f7lVK7AifdRhZ14mIHvBk5ROqtbtEkpEUekVI=; b=PStwN8J9WglnPwSrV0dM3AVahzXE6kSqMbbkzaOjiLnRigpJdtZbsznzA6h0ZHFxCl VCc2EwXkgQTpc2I8msSXawKjWhovEq4qPlEq9FHqwcAnhsRf38LfjGSr2OksXXnBDVe5 D2AXYVst8rALAmrORJawmosR19EMmGOJojF8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:reply-to:from:in-reply-to :content-transfer-encoding; bh=vJfBn+f7lVK7AifdRhZ14mIHvBk5ROqtbtEkpEUekVI=; b=gNlNLLu2Hdn7x2O+oc2n+O/NmCIpI7jcdrwOjoCaL0zFkAjZU+cLtoZGNqtP1u/nwd D3GbFuL8R/DZbidMDGwzmE6GVdIbNihvpGUEZKfeiK0ZaR4ObAUA+ZZNM5wr6/u6p3Gn 4ORQ+X0AtcOzOR4E9ab/BiUDmBv+hTp8/rQOtX2R/WMZuGqdhgiHeteawD5IgkYZTjVI r2bjzgiupzvRPMcRGz7UF4oTnzlq95TF/dJZNwitrVuP6yQy9GRcLu1tPTXqA8vCYcyL nO/LqJAYCVU31ZO1RANFhwB05/rSZ+J5iH/kKwob+/MrSsZNKREx2FYweUd4mTZn8rn1 eOAQ== X-Gm-Message-State: AJIora/lNErg0pX952n1jGwyihCbc8Hd54vOm+V431WNlaOlRG1skC6l 19EiJd7+UzEsrb2MoHfkTFWn9A== X-Received: by 2002:a05:6870:649e:b0:ed:a1c0:f810 with SMTP id cz30-20020a056870649e00b000eda1c0f810mr285467oab.289.1656434689573; Tue, 28 Jun 2022 09:44:49 -0700 (PDT) Received: from [192.168.0.41] ([184.4.90.121]) by smtp.gmail.com with ESMTPSA id y27-20020a544d9b000000b0032b99637366sm4400950oix.25.2022.06.28.09.44.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jun 2022 09:44:49 -0700 (PDT) Message-ID: <83b9774f-5cda-d05f-e62d-7bf7547ae7ba@cloudflare.com> Date: Tue, 28 Jun 2022 11:44:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH 0/2] Introduce security_create_user_ns() Content-Language: en-US To: KP Singh , Casey Schaufler Cc: Paul Moore , Daniel Borkmann , Christian Brauner , revest@chromium.org, jackmanb@chromium.org, ast@kernel.org, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, jmorris@namei.org, serge@hallyn.com, bpf@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com References: <20220621233939.993579-1-fred@cloudflare.com> <20220627121137.cnmctlxxtcgzwrws@wittgenstein> <6a8fba0a-c9c9-61ba-793a-c2e0c2924f88@iogearbox.net> <685096bb-af0a-08c0-491a-e176ac009e85@schaufler-ca.com> <9ae473c4-cd42-bb45-bce2-8aa2e4784a43@cloudflare.com> Reply-To: CACYkzJ6GmotfhBk1+9BjGC6Ct7bGxQGVTZTX2iQcrhjfV7VHwQ@mail.gmail.com From: Frederick Lawler In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/28/22 11:12 AM, KP Singh wrote: > On Tue, Jun 28, 2022 at 6:02 PM Casey Schaufler wrote: >> >> On 6/28/2022 8:14 AM, Frederick Lawler wrote: >>> On 6/27/22 6:18 PM, Casey Schaufler wrote: >>>> On 6/27/2022 3:27 PM, Paul Moore wrote: >>>>> On Mon, Jun 27, 2022 at 6:15 PM Daniel Borkmann wrote: >>>>>> On 6/27/22 11:56 PM, Paul Moore wrote: >>>>>>> On Mon, Jun 27, 2022 at 8:11 AM Christian Brauner wrote: >>>>>>>> On Thu, Jun 23, 2022 at 11:21:37PM -0400, Paul Moore wrote: >>>>>>> ... >>>>>>> >>>>>>>>> This is one of the reasons why I usually like to see at least one LSM >>>>>>>>> implementation to go along with every new/modified hook. The >>>>>>>>> implementation forces you to think about what information is necessary >>>>>>>>> to perform a basic access control decision; sometimes it isn't always >>>>>>>>> obvious until you have to write the access control :) >>>>>>>> I spoke to Frederick at length during LSS and as I've been given to >>>>>>>> understand there's a eBPF program that would immediately use this new >>>>>>>> hook. Now I don't want to get into the whole "Is the eBPF LSM hook >>>>>>>> infrastructure an LSM" but I think we can let this count as a legitimate >>>>>>>> first user of this hook/code. >>>>>>> Yes, for the most part I don't really worry about the "is a BPF LSM a >>>>>>> LSM?" question, it's generally not important for most discussions. >>>>>>> However, there is an issue unique to the BPF LSMs which I think is >>>>>>> relevant here: there is no hook implementation code living under >>>>>>> security/. While I talked about a hook implementation being helpful >>>>>>> to verify the hook prototype, it is also helpful in providing an >>>>>>> in-tree example for other LSMs; unfortunately we don't get that same >>>>>>> example value when the initial hook implementation is a BPF LSM. >>>>>> I would argue that such a patch series must come together with a BPF >>>>>> selftest which then i) contains an in-tree usage example, ii) adds BPF >>>>>> CI test coverage. Shipping with a BPF selftest at least would be the >>>>>> usual expectation. >>>>> I'm not going to disagree with that, I generally require matching >>>>> tests for new SELinux kernel code, but I was careful to mention code >>>>> under 'security/' and not necessarily just a test implementation :) I >>>>> don't want to get into a big discussion about it, but I think having a >>>>> working implementation somewhere under 'security/' is more >>>>> discoverable for most LSM folks. >>>> >>>> I agree. It would be unfortunate if we added a hook explicitly for eBPF >>>> only to discover that the proposed user needs something different. The >>>> LSM community should have a chance to review the code before committing >>>> to all the maintenance required in supporting it. >>>> >>>> Is there a reference on how to write an eBPF security module? >>> >>> There's a documentation page that briefly touches on a BPF LSM implementation [1]. >> >> That's a brief touch, alright. I'll grant that the LSM interface isn't >> especially well documented for C developers, but we have done tutorials >> and have multiple examples. I worry that without an in-tree example for >> eBPF we might well be setting developers up for spectacular failure. >> > > Casey, Daniel and I are recommending an in-tree example, it will be > in BPF selftests and we will CC you on the reviews. > > Frederick, is that okay with you? Yep. > >>> >>>> There should be something out there warning the eBPF programmer of the >>>> implications of providing a secid_to_secctx hook for starters. >>>> >>> >>> Links: >>> 1. https://docs.kernel.org/bpf/prog_lsm.html?highlight=bpf+lsm# >>>