Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp550446rwb; Tue, 27 Sep 2022 00:56:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7mM5PWQYUR2sBXERNiqawML2Jt3gro58puipavCX5PecPaMREe1ITrEeVfSXiougnO6Edz X-Received: by 2002:a17:902:d54d:b0:178:a62d:d4e6 with SMTP id z13-20020a170902d54d00b00178a62dd4e6mr26408864plf.73.1664265389623; Tue, 27 Sep 2022 00:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664265389; cv=none; d=google.com; s=arc-20160816; b=pfIy8QdfOqnhxu2IcxK+2gV9K8YbyvUrrJ/nup9y9o1d5m4X+OFDx040JXpTQ9i8KJ kLJ9FXH4ZhgfyMDLxfzebr27ffS2GJ8Xkwfuu7qaz5eXWupTiIE+aBibFWqRrFBBOFYk xMPvoJEWJCvQTB4Ac9To0M+WOSoRQYoJBVXnQVRfdGkU4Vpl3UifjtNyYFCCadiKXXvu L1UKG0Gc+Lt8SwOROuiTBwJNghpCNlOj1z+IMiPv/c8uaL9x56W3+ooIIt1h6xqqllbS 8s3nhC6fb4Vx/AI+YJeqfs+f9U/GU+HArc8J1R+KvtxwDRBBo6iKWOOP2q0m+eRHaRoS rx4w== 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 :references:message-id:subject:cc:to:from:date:dkim-signature; bh=whF8yVmdeBs36T7BK6ZlIxxrwmhicSZaQh7tKxgNWww=; b=Ckri9N/b4pzR+4tKxec28n8RmiJ7lWcWiFQ8SIgb8tsNEqC7ZaWERES8nxDxl6grzF WWn+jwEHgYO1R9/cZOs95gagfaEWwynzCDRXA/jKvnfc2OUKVyrvEfeXjMF1fX4pV3/V e7SJGgNaGVRzFJSP+w/YzGdkWm+0HtZvi7nmwcz8baF3ZtNwSx5YR6SNaJ4X1P1zVWyg d3VLaPmOJh3tYJsDYy+2gxrfVDPGIyb+Ibytju17aBD6YShu8qxFKoF0sqGEFq4cTTnf dvsolCEG7RlyWqMINFILB7QTifYJ2CPQI1eUnfY3KHUp8kkz9WRDHnI9MvvRI+IiN96B f+8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a7yA5+sk; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a056a00228100b00537e328e742si1638675pfe.1.2022.09.27.00.56.16; Tue, 27 Sep 2022 00:56:29 -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=@linuxfoundation.org header.s=korg header.b=a7yA5+sk; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbiI0H1X (ORCPT + 99 others); Tue, 27 Sep 2022 03:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbiI0H1Q (ORCPT ); Tue, 27 Sep 2022 03:27:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 142525A839; Tue, 27 Sep 2022 00:27:14 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A4BC661633; Tue, 27 Sep 2022 07:27:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CAEAC433D6; Tue, 27 Sep 2022 07:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664263633; bh=SI3kVzyecrOMD/bcba3UfKjYRRQPvyugPiizWjjNlW8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a7yA5+skaquN4y+vevefsEkQE6uigIxphkNMmk9rkL2DRmNXZJBAr6VWB+5frE/pV V89bwhx2dfKLSUW5ZBhl68d4D/lrRYoWG3MbKOZwVAotK+6SqLhTSmbIRLhnIeNUyW iqT6ETmIrMTZs2B4dGuajdB/iz8jr+eViHmhBIZw= Date: Tue, 27 Sep 2022 09:27:10 +0200 From: Greg Kroah-Hartman To: ira.weiny@intel.com Cc: Dan Williams , Bjorn Helgaas , Jonathan Cameron , Alison Schofield , Vishal Verma , Ben Widawsky , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH V3 1/2] PCI: Allow drivers to request exclusive config regions Message-ID: References: <20220926215711.2893286-1-ira.weiny@intel.com> <20220926215711.2893286-2-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220926215711.2893286-2-ira.weiny@intel.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Mon, Sep 26, 2022 at 02:57:10PM -0700, ira.weiny@intel.com wrote: > From: Ira Weiny > > PCI config space access from user space has traditionally been > unrestricted with writes being an understood risk for device operation. > > Unfortunately, device breakage or odd behavior from config writes lacks > indicators that can leave driver writers confused when evaluating > failures. This is especially true with the new PCIe Data Object > Exchange (DOE) mailbox protocol where backdoor shenanigans from user > space through things such as vendor defined protocols may affect device > operation without complete breakage. > > A prior proposal restricted read and writes completely.[1] Greg and > Bjorn pointed out that proposal is flawed for a couple of reasons. > First, lspci should always be allowed and should not interfere with any > device operation. Second, setpci is a valuable tool that is sometimes > necessary and it should not be completely restricted.[2] Finally > methods exist for full lock of device access if required. > > Even though access should not be restricted it would be nice for driver > writers to be able to flag critical parts of the config space such that > interference from user space can be detected. > > Introduce pci_request_config_region_exclusive() to mark exclusive config > regions. Such regions trigger a warning and kernel taint if accessed > via user space. > > Create pci_warn_once() to restrict the user from spamming the log. > > [1] https://lore.kernel.org/all/161663543465.1867664.5674061943008380442.stgit@dwillia2-desk3.amr.corp.intel.com/ > [2] https://lore.kernel.org/all/YF8NGeGv9vYcMfTV@kroah.com/ > > Cc: Bjorn Helgaas > Cc: Greg Kroah-Hartman > Reviewed-by: Jonathan Cameron > Suggested-by: Dan Williams > Signed-off-by: Ira Weiny Acked-by: Greg Kroah-Hartman