Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1094336pxb; Wed, 6 Apr 2022 08:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUAFxP6ziyIpJuHaxbQWeFw2t/T9leGmhQllGy5dCAD2xBTy5X9mwlCJrg2mGVmjKkSRHV X-Received: by 2002:a17:902:e80c:b0:156:bc53:704e with SMTP id u12-20020a170902e80c00b00156bc53704emr8957113plg.31.1649259294050; Wed, 06 Apr 2022 08:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649259294; cv=none; d=google.com; s=arc-20160816; b=iY4Awvlk/txUXrgqwzGT2avbxHXcEAeXEkncdpF5HP8ooOzYYTzi4f3hufNn9ix9uX NnCg4lYzdV9r+7uSEuYfgVeNkydZZKy2uUX9BpJHsf666Ofca4nJMjeqnNmHmskM7lpJ zVPHhPipba+Qq4E9P8T+gD5Es14qUPNxqtrVwdhOXQu+szTS79CwpzaY8DbrQcM0fZUz q7V6X4gSt99+KWKfqAKmQ89Re1WVqQsheUvz/ESSrRVp/w8hP0QgzC3rcOr1fTkM4KJJ 0F95uEiEmzJaV7R6kDLn0oE1NNdzpJFFh6dUtT+wu2NeV67ol1fWKiXzLLxQcHwE8dQa yoKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=e8i5MiSj0UtEhnoqXJUv4ImpuyyDLVGicL1RIOGnIjE=; b=OMVfQyltvwlZZ1Rt+9jirfIy48HwCpDN2EC90D5gqFa1/ZvIMhOOLN7RjuLwH1jQzD WRVvgryQa7hVHcDAHI2sFy2j+/XYgC1z90p2VgGB1F+XMduyzdICpnYJ8e8gpCTC6W/9 QYXgO7QFq6+beigN7Z3vi0UMvp/4gdluYBC3ZQ1+wJYV0u9ajV3kdTeOEPlsWbl6BBNT cl2ewO+tnZSba08wxhvoRwaIYnFe7y++xuVUpOZmf01O8x0abAbzTx4c877r1EjRRAKX fo3PwzBb48xg3WfAWe+HMlB3lSxGkbc/91QdowKBAaCcQV72NZzGy9UO18LfC0OK+WIX UOxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r3tjcj3E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e16-20020a63db10000000b003816043ee60si15289371pgg.85.2022.04.06.08.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:34:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r3tjcj3E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 596C7329B75; Wed, 6 Apr 2022 06:47:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233900AbiDFNtw (ORCPT + 99 others); Wed, 6 Apr 2022 09:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbiDFNtc (ORCPT ); Wed, 6 Apr 2022 09:49:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B00B66D1B68; Wed, 6 Apr 2022 04:17:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 68401B82014; Wed, 6 Apr 2022 11:17:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE273C385A3; Wed, 6 Apr 2022 11:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649243874; bh=7LHnVNHcEpVspRSCfG1S+Ca+XYKk7J8eU7YTFtzdfYI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=r3tjcj3EM5yCFNFZOvxZ8VmWUC2KgykSEsAsh26vJHbZc8GehVMB58ImJfzOJOCHN l/CUQltVX6S2BK5NhGYZXYg3+G2gPIQs0mQ4eV08paTjUnMv0bjJ3PVX2Rgta96Yi6 2eoZUhFtXk313tib0tsUbGV+TaWqT7ORMqxgFzcUCM69x/46qwOlm/IofdiVsLTEgk Nu9LhLVwZXaxDAn0DJQMiADlfyf02NHxANnWXmIfV+t7i/Po4ycMjfPE6p7raFdVxY urq7Fm9JuXlK1DbDwfohaxpaxD0b4LzIyqS3GWDXrBra9Ei7t0lceqh95uADMOcL6B 9olZAcSnD8m1g== Date: Wed, 6 Apr 2022 06:17:51 -0500 From: Bjorn Helgaas To: David Stevens Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [RFC] PCI: sysfs: add bypass for config read admin check Message-ID: <20220406111751.GA132418@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220406071131.2930035-1-stevensd@google.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_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 [+cc Kees] On Wed, Apr 06, 2022 at 04:11:31PM +0900, David Stevens wrote: > From: David Stevens > > Add a moduleparam that can be set to bypass the check that limits users > without CAP_SYS_ADMIN to only being able to read the first 64 bytes of > the config space. This allows systems without problematic hardware to be > configured to allow users without CAP_SYS_ADMIN to read PCI > capabilities. Can you expand this a bit to explain the purpose of this? I guess it makes "lspci -v" work without having to be root? How much of a problem is that? Is there some specific use case that needs this change? Maybe there's some way to address that without having to add a new parameter that bypasses CAP_SYS_ADMIN. > Signed-off-by: David Stevens > --- > drivers/pci/pci-sysfs.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > index 602f0fb0b007..162423b3c052 100644 > --- a/drivers/pci/pci-sysfs.c > +++ b/drivers/pci/pci-sysfs.c > @@ -28,10 +28,17 @@ > #include > #include > #include > +#include > #include "pci.h" > > static int sysfs_initialized; /* = 0 */ > > +static bool allow_unsafe_config_reads; > +module_param_named(allow_unsafe_config_reads, > + allow_unsafe_config_reads, bool, 0644); > +MODULE_PARM_DESC(allow_unsafe_config_reads, > + "Enable full read access to config space without CAP_SYS_ADMIN."); > + > /* show configuration fields */ > #define pci_config_attr(field, format_string) \ > static ssize_t \ > @@ -696,7 +703,8 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, > u8 *data = (u8 *) buf; > > /* Several chips lock up trying to read undefined config space */ > - if (file_ns_capable(filp, &init_user_ns, CAP_SYS_ADMIN)) > + if (allow_unsafe_config_reads || > + file_ns_capable(filp, &init_user_ns, CAP_SYS_ADMIN)) > size = dev->cfg_size; > else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) > size = 128; > -- > 2.35.1.1094.g7c7d902a7c-goog >