Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp455333ybt; Mon, 6 Jul 2020 13:33:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcemybUtOvEYoiN9BwUkosUxy2yPv3CrQ+BYt2xxrVfPuWQnioLASZe3CjB9TpW4SW/KXv X-Received: by 2002:a50:e14e:: with SMTP id i14mr55476304edl.279.1594067596510; Mon, 06 Jul 2020 13:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594067596; cv=none; d=google.com; s=arc-20160816; b=jyCYaZdR10lmMe41Q5nTEvA1GluHzwTT7+AEtrcQHMtQqHPrHAfwaSYPUC1R12ho0g tz2QRrmbtdToW4JBXqQR68asQihTqp1VYCaFHvPAsYn5VFaDX2Trniy4fpGdAzj1HTLz LENUUklx7Wyk2PZmPS45fziYD/36SKXvBGcITRR+EGtzMflYbHZFLXi1JzHmi1PQuhyR RHQdoSTDAkWSfHTfCZlPmofPeA2zg0dd2vO6fZY9RE0jdX7HBY4gARmMNqioaytbAaDk d3wbRcLTQInRywpupNYlfeAfUnItlV8a9tH77suwMaPspQ2CW/fhljpuyixolQY/+8vw 3zqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=b00l0G+v45Z6tIxVmpU8zc8V+eHm6VMqCzw//xyzaXg=; b=af3u52lnsqanNDovFx54vznfOFapX4OJ3E7zIMuvHpgKaoA+3ruDDGRCftoIFXXzyA t4tFb2I4cQ1lDcKZ0vuSNekczh5m0S/Sg9VSL8QSbBHgc1heqmwXAlFRu02TDnPx4vtH vn22iZxtuWiu+gb1Ym2//DWD5GyNi/yn39Hog/uB3e8Vpm7i7qgR6CxNCE/wzrWGGdTe c8t9Mf9f6kMTdyUIGFN93uodGaBs+xASWGTi2udIPDTjgMXJzvj86OG84DFt3+lqxZJ2 nrJfOs3902KRCazR5641+tzuOUfvSLcWqomruMy9+AG+uV1SzXvZFGEewNJTuHS6nzfl NTmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Ac/VoY7B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id i12si14064181edq.340.2020.07.06.13.32.53; Mon, 06 Jul 2020 13:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Ac/VoY7B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726634AbgGFUbC (ORCPT + 99 others); Mon, 6 Jul 2020 16:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgGFUbB (ORCPT ); Mon, 6 Jul 2020 16:31:01 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 290E1C061755 for ; Mon, 6 Jul 2020 13:31:01 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id z2so20375211wrp.2 for ; Mon, 06 Jul 2020 13:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=b00l0G+v45Z6tIxVmpU8zc8V+eHm6VMqCzw//xyzaXg=; b=Ac/VoY7BZFHgX6kKaPiIAhNAqsNuZHFvXEVjQHFhp+JipFaTKiLwOCsJichH8N/rmV fgxylTgGY1CHeSyVq4+h4/u1lbaRFBUMmVw7qS1zxFtuN9wZBumR9qzyWD4CPpANWweN uncBbqUzwecZP1Z4mjyC429r2imOn/w4Sj1Uc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=b00l0G+v45Z6tIxVmpU8zc8V+eHm6VMqCzw//xyzaXg=; b=qgK/0tb88MEmXquvmxxWhtKkkF26fCYikK3DFrNte1TntR5bKnlW7Vv+mIDhw0Aks2 Y0c5Bks3IVaSEZNPQKbQDnZcxAk2+WJc7ljtDFtNkr9jL74taoZ6x4menEiiS/qEMDJ0 2uVnrKut9gVcnOtjEkz209XIUQNwJINe7En/GAa3spD96/i50ED2fWAxzv3SQWXRTcwk ru3bN33lDlT5Pc1PO09PEv9ldmPLWURgz+D6PMtsjehfHUNtSE+3nLPRN+NTcETaFcce 0v7clr0myd8Zq68iow16Yv8F7y8WHj7PcI2p2MTAtwMjxsQLll0+NAyG9ZvG4NsjvedF kppg== X-Gm-Message-State: AOAM5309tPWbSGL5jwKkc1INSFepOMxNWU8H384MTUo9OODHkAW9MKDV Z7idCplkaQWXXbs4KtLb/xBeZSEJ+da0jgQ9zNXJLA== X-Received: by 2002:a05:6000:86:: with SMTP id m6mr17934611wrx.173.1594067459857; Mon, 06 Jul 2020 13:30:59 -0700 (PDT) MIME-Version: 1.0 References: <20200706165710.GA208695@gallifrey> <9268bd47-93db-1591-e224-8d3da333636e@iogearbox.net> <20200706200640.GA234619@gallifrey> In-Reply-To: <20200706200640.GA234619@gallifrey> From: KP Singh Date: Mon, 6 Jul 2020 22:30:49 +0200 Message-ID: Subject: Re: [PATCH] bpf: lsm: Disable or enable BPF LSM at boot time To: Lorenzo Fontana , KP Singh , Daniel Borkmann , open list , bpf , Linux Security Module list , Jonathan Corbet , James Morris , "Serge E. Hallyn" , Alexei Starovoitov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , Paul Moore , Stephen Smalley Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 6, 2020 at 10:06 PM Lorenzo Fontana wrote: > > On Mon, Jul 06, 2020 at 08:59:13PM +0200, KP Singh wrote: > > On Mon, Jul 6, 2020 at 8:51 PM Daniel Borkmann wrote: > > > > > > On 7/6/20 6:57 PM, Lorenzo Fontana wrote: > > > > This option adds a kernel parameter 'bpf_lsm', > > > > which allows the BPF LSM to be disabled at boot. > > > > The purpose of this option is to allow a single kernel > > > > image to be distributed with the BPF LSM built in, > > > > but not necessarily enabled. > > > > > > > > Signed-off-by: Lorenzo Fontana > > > > > > Well, this explains what the patch is doing but not *why* you need it exactly. > > > Please explain your concrete use-case for this patch. > > > > Also, this patch is not really needed as it can already be done with the current > > kernel parameters. > > > > LSMs can be enabled on the command line > > with the lsm= parameter. So you can just pass lsm="selinux,capabilities" etc > > and not pass "bpf" and it will disable the BPF_LSM. > > > > - KP > > > > > > > > Thanks, > > > Daniel > > Hi, > Thanks Daniel and KP for looking into this, I really appreciate it! > > The *why* I need it is because I need to ship the kernel with BPF LSM > disabled at boot time. > > The use case is exactly the same as the one described by KP, however > for a personal preference I prefer to pass specifically bpf_lsm=1 or > bpf_lsm=0 - It's easier to change programmatically in my scripts > with a simple sprintf("bpf_lsm=%d", value). I do the same > with "selinux=1" and "selinux=0" in my systems. > From what I can see by reading the code and testing, the two ways > bot act on 'lsm_info.enabled' defined in 'lsm_hooks.h'. > So it's not just a personal preference, I just want the same set > of options available to me as I do with selinux. The "selinux=" option existed before the "lsm=" parameter was added and it now exists only for backward compatibility. I added Paul and Stephen to Cc who might have more information about this. - KP > > Thanks a lot, > Lore