Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3649279pxu; Mon, 19 Oct 2020 18:27:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNnWKInvtpFMsVdG56yZhDOW/Mw+4dC2eySGAj5JKATanPX+5pkrPqUafIt+oR6zxqiEJ7 X-Received: by 2002:a17:907:2056:: with SMTP id pg22mr683401ejb.177.1603157273793; Mon, 19 Oct 2020 18:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603157273; cv=none; d=google.com; s=arc-20160816; b=SKCb1jtPG2tMt30cLlRU42YFV1AbY+boocoyrM4Ir9JTh1hUrA2DEe2MTqy7JxcDxM o9xCHkLuTY5oNrFWmmsx3PCH41yzrEaWD5g/OU7xxlnOqZnhFO+IxEcrE6FhA38MZfQe IQAXEvdgigagRpB1evoeO+Mh9GXKkJ8YFq2yzEFb9FopUZJq5PY/0I/ibLiJEkYIMQXv JsNYXoHv+hRsMmD3iLXLo8R+TQyth3Lvp37LPAzO2FhIlAq7M4bgfcVVfzkAwIIFyHWM CjYyYN8mbQbDh3BrdQJCFUIasxpM30DM63/u0YKVDFVzOMGnHrlJDv1Lqe1thQFJPFZP x0sA== 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=ign/EeDUjTI/ZnAWA89QE6u0GO9O0Zt8VlQPXvX86Ak=; b=ia7UQNZ6NPYyVaV4/buZNHf6OQqn7qdeZ8PO4JwLtmhAbVI0+H0aJXHzqu8Y2YNE2I EAWOnJ98LkSI5fzgRarTW/B5kDv/+TW8RwksRokuHqO4z4/9fxGmku9XvYoWaaZ8zfcC Q4rJ3Syi5Wya11w+skpbcYqe3bnq2uNiXxGXjgCMi3ntpb3psh7UkVJcleTF2W6klnBe CipzvCZhIvAHD3dihrItbjRgpfUOqIV1+dZ8mowPdHaxpQc/nv3YuCF00IMK1hgxeDSs SfK8hI1KLiUez2U+OcKkV0qUPxhVkWz338iNkmxvdeBv3Ohde73Tgzj+30UmkbOVIn+B BQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DZBTMBDM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx6si231553ejb.613.2020.10.19.18.27.32; Mon, 19 Oct 2020 18:27:53 -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=@kernel.org header.s=default header.b=DZBTMBDM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728667AbgJSNqq (ORCPT + 99 others); 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-kernel@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