Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4920426ybb; Tue, 24 Mar 2020 07:44:20 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtMKgkNF115dM1Q+vDtOclNDXesFVQNMF1dtFEwYm6WNcVXF08GwjmZMtuliET6azW7Q686 X-Received: by 2002:a9d:6b16:: with SMTP id g22mr4711265otp.37.1585061059883; Tue, 24 Mar 2020 07:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585061059; cv=none; d=google.com; s=arc-20160816; b=aIC43TSU2JrBCbtC02kXL9Omo7vDym87n+kb3BCqcNG7vviKilrChxFYWumE1auzRS 4jPFt3q0qSPtRj1HBdflxI+WMW0kP20SQxJzSSD1PdiSX9k49QghLe2YmLQ+tweDFzyL Bq9NXBNw/vQO6L1WqpmC/HsroYgLeZokZfj/nADYd2mRPTqtIB9ZoZIL+0ZVeCTqB3wc CBUdVmItgW5MCBreydXprhhRwg/7TsSHrOUenSNZJYES8gf6X/0CMi8KRdVvpe3A4o7H I2/3rSpz13GlO23i5vMD3sh98aYwO2wGRu6QMc8naXJqhIlXx3pPXjj66dr9135dwSMo npvA== 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=7vTrTxx0I42zw2BaG0USTFej0dtrrNyaNSAnPWYt9Eo=; b=TJOzbPFoi1Tjmk1iNRRABR9fsF+odzCV78cUATRedjQ8sy60UtAAkOW1cYwekUq5BE /pjL93BtCokVGTksYNbPrnEB+hjIanJN8TsNhMYIGSEd6xmwL5ZjCQUALuWzb69kLseH rDItGWIpyVFwhnn0t48aE6R7PFrpvRb9pQOgvx4BxL/4yu8z7cyGZdX8vAf/PHMHA8PI KIql2da66zCOZ8Un12KpVfrRPzNnwt1/0Do78WVzQGGMePIE0raQtz1ERPQgAnA/9OZX TpnaK6WEixLXw+i3qKkokeMTekJ5JkQzJZCy1EUt54OGLioD5RfMK+ROx/tZLizS+Qo/ yWwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dkufhUJ9; 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 w5si1623989ote.129.2020.03.24.07.44.06; Tue, 24 Mar 2020 07:44:19 -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=dkufhUJ9; 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 S1727703AbgCXOmT (ORCPT + 99 others); Tue, 24 Mar 2020 10:42:19 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37589 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727535AbgCXOmT (ORCPT ); Tue, 24 Mar 2020 10:42:19 -0400 Received: by mail-wr1-f68.google.com with SMTP id w10so21800466wrm.4 for ; Tue, 24 Mar 2020 07:42:18 -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=7vTrTxx0I42zw2BaG0USTFej0dtrrNyaNSAnPWYt9Eo=; b=dkufhUJ9zQgyP8eGpXezEO6a9c0CgpImFYcOb7SPCPnxkVXnUCf9MubJp0Db51xEiq qINGVez4sAiuIZTWVRXxyECGEj+Tt0lNCg0T/cuaWJn6rLAyv22itIBOF196q7ArZrkG Np68R2299lTO/aD1jrc6693/loNDi3KzSYUtE= 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=7vTrTxx0I42zw2BaG0USTFej0dtrrNyaNSAnPWYt9Eo=; b=ia+8WoHlAeBzeNb/kqt998Rwg9KLcii5up5xnvJlrdRu0W5b9pnsY613z7szvS3ShO hfkC3bWb8D/CSSakLAX08Ly8ZObG2CzuY1sd8v+ekt/8jy5IGOjN9wv5xjNCIyFrXxOW GoAviTfyHgzt9WKfImS9dh1JNXmlOWzvYvB49zb8fqiGNvZHdw8Rvkv3VqgAXeFBpRSO U2jDXOlE+mDEwdu+b3/fev/s4HakV1aqCx8vX1XGSSaAXAtgM7JnFjjm7z0GmQaaCrZd GU7pLUEuxQPi8BmjD9f+x+oA535gDRiycWKg/X3l41CxWzczIQSPfyU62Pj71mOEMP/b kmiA== X-Gm-Message-State: ANhLgQ13wQ+EMjr90LwqfadHelqxRU/9X6nlXKGuF43LKlAClLZsikt9 sbE6SeVFvE1inAIwuS6ZFZLY7g== X-Received: by 2002:a5d:6888:: with SMTP id h8mr27440636wru.159.1585060937530; Tue, 24 Mar 2020 07:42:17 -0700 (PDT) Received: from chromium.org (77-56-209-237.dclient.hispeed.ch. [77.56.209.237]) by smtp.gmail.com with ESMTPSA id s15sm30790432wrr.45.2020.03.24.07.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 07:42:16 -0700 (PDT) From: KP Singh X-Google-Original-From: KP Singh Date: Tue, 24 Mar 2020 15:42:14 +0100 To: Stephen Smalley Cc: Casey Schaufler , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, LSM List , Brendan Jackman , Florent Revest , Alexei Starovoitov , Daniel Borkmann , James Morris , Kees Cook , Paul Turner , Jann Horn , Florent Revest , Brendan Jackman , Greg Kroah-Hartman Subject: Re: [PATCH bpf-next v5 5/7] bpf: lsm: Initialize the BPF LSM hooks Message-ID: <20200324144214.GA1040@chromium.org> References: <20200323164415.12943-1-kpsingh@chromium.org> <20200323164415.12943-6-kpsingh@chromium.org> <6d45de0d-c59d-4ca7-fcc5-3965a48b5997@schaufler-ca.com> <20200324015217.GA28487@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 24-M?r 10:37, Stephen Smalley wrote: > On Mon, Mar 23, 2020 at 9:52 PM KP Singh wrote: > > > > On 23-M?r 18:13, Casey Schaufler wrote: > > > On 3/23/2020 9:44 AM, KP Singh wrote: > > > > From: KP Singh > > > > > > > > The bpf_lsm_ nops are initialized into the LSM framework like any other > > > > LSM. Some LSM hooks do not have 0 as their default return value. The > > > > __weak symbol for these hooks is overridden by a corresponding > > > > definition in security/bpf/hooks.c > > > > > > > > + return 0; > > > > [...] > > > > > > +} > > > > + > > > > +DEFINE_LSM(bpf) = { > > > > + .name = "bpf", > > > > + .init = bpf_lsm_init, > > > > > > Have you given up on the "BPF must be last" requirement? > > > > Yes, we dropped it for as the BPF programs require CAP_SYS_ADMIN > > anwyays so the position ~shouldn't~ matter. (based on some of the > > discussions we had on the BPF_MODIFY_RETURN patches). > > > > However, This can be added later (in a separate patch) if really > > deemed necessary. > > It matters for SELinux, as I previously explained. A process that has > CAP_SYS_ADMIN is not assumed to be able to circumvent MAC policy. > And executing prior to SELinux allows the bpf program to access and > potentially leak to userspace information that wouldn't be visible to > the > process itself. However, I thought you were handling the order issue > by putting it last in the list of lsms? We can still do that if it does not work for SELinux. Would it be okay to add bpf as LSM_ORDER_LAST? LSMs like Landlock can then add LSM_ORDER_UNPRIVILEGED to even end up after bpf? - KP