From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BC13C433E7 for ; Mon, 19 Oct 2020 13:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9D09222D9 for ; Mon, 19 Oct 2020 13:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603115206; bh=SSi7/lPpg93zvX4ef4Gp1/L433ZTE79+nFhtyAnpYqo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=cLCiWeUNeXBT40k/pq6MHXaV+frOhMRZqOHE3Xf3VxlMbxTJjCh9EIECJbbckT4ss 8uNpAz0ruuBTAHjduhRsq5Vqnc40GB+jxuuLMjcOWuRgOhv1YMrc4n0ghDjIF0DPGj B9LpYm7fMRlMqOJtvlaD+Z75Vg/vePPm6WXe8AuY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728425AbgJSNqq (ORCPT ); Mon, 19 Oct 2020 09:46:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:56272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbgJSNqp (ORCPT ); Mon, 19 Oct 2020 09:46:45 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 114A422268; Mon, 19 Oct 2020 13:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603115204; bh=SSi7/lPpg93zvX4ef4Gp1/L433ZTE79+nFhtyAnpYqo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DZBTMBDM6CPqELhcRAiWDMeQ7qjrzt3GOhjPUl4tZ/47E/i/H4S2u1AFMWyIWTNR1 5EIOBM/Zkyqha3VEy7KkL5cHyiHplelrtRv770wOW7+eCU7W7apAGTkgmxQ7k6yKjC /9uwYwfyIqpOGsYE0YOZfD0m9aiVNzkCandV4zto= Date: Mon, 19 Oct 2020 15:47:29 +0200 From: Greg KH To: Allen Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , ast@kernel.org, Linux Kernel Mailing List , Allen Pais , Allen Pais Subject: Re: [RFC] PCI: allow sysfs file owner to read the config space with CAP_SYS_RAWIO Message-ID: <20201019134729.GA3259788@kroah.com> References: <20201016055235.440159-1-allen.lkml@gmail.com> <20201016062027.GB569795@kroah.com> <20201019131613.GA3254417@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Mon, Oct 19, 2020 at 06:51:39PM +0530, Allen wrote: > > > > > > > > > > Access to pci config space is explictly checked with CAP_SYS_ADMIN > > > > > in order to read configuration space past the frist 64B. > > > > > > > > > > Since the path is only for reading, could we use CAP_SYS_RAWIO? > > > > > > > > Why? What needs this reduced capability? > > > > > > Thanks for the review. > > > > > > We need read access to /sys/bus/pci/devices/, We need write access to config, > > > remove, rescan & enable files under the device directory for each PCIe > > > functions & the downstream PCIe port. > > > > > > We need r/w access to sysfs to unbind and rebind the root complex. > > > > That didn't answer my question at all. > > Sorry about that, breaking it down: > > When the machine first boots, the VFIO device bindings under /dev/vfio > are not present. > > root@localhost:/tmp# ls -l /dev/vfio/ > total 0 > crw-rw-rw-. 1 root root 10, 196 Jan 5 01:47 vfio > > We have an agent which needs to run the following commands (We get > access denied here and need permissions to do this). > echo -n xxxx yyyy > /sys/module/vfio_pci/drivers/pci:vfio-pci/new_id > echo -n xxxx yyyy > /sys/module/vfio_pci/drivers/pci:vfio-pci/new_id > > And we want to avoid handing CAP_SYS_ADMIN here. Which is why the > thought about CAP_SYS_RAWIO. But that is not what you were asking this patch to do at all. So why bring it up? new_id is NOT for "raw io" control, that should be only for admin priviliges. And just because the vfio driver "abuses" this traditionally-debug-functionality doesn't mean you get to abuse the permission levels either. > > Why can't you have the process that wants to do all of the above, have > > admin rights as well? Doing all of that is _very_ low-level and can > > cause all sorts of horrible things to happen to your machine, and is not > > really "raw io" in the traditional sense at all, right? > > > If the above approach is going to cause the system to do horrible things, > then I'll drop the idea. Of course it can cause the system to do horrible things, try it yourself and see! greg k-h