Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3245321pxu; Mon, 19 Oct 2020 07:35:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc5kH/cFscv/PkOTkd0g74uAWLR5/B1FbFTL8tSe71fZ1ZD1R1RG8FFXJrLSyyLP1Ph4uW X-Received: by 2002:aa7:cacd:: with SMTP id l13mr61347edt.177.1603118105276; Mon, 19 Oct 2020 07:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603118105; cv=none; d=google.com; s=arc-20160816; b=Wc7i4ubAv3Ie1qA2QGugZrAFRwTVxiU5ugPn03OmuK1kiwbYfzOS679uF3oTz1RUwy cRovHXTOeXlYPy6IfvBPDRXZmPyzOvh9tAGZPnl5R5Y591355uyiLby6vz1yHXagCshw 1Uk4UISy7uz8rHwu87xbIvdeD08QFr6RYrdudC4bJMqxnhNIOEcUu8Fj4spLNO2gqQIc F14xfycROfUIFjkmfiFJimhnuuNCjI9PJpS+6GLWoECGSKcEnUSn4UNtd/sVpRxFU1ln 6VD0VVoG8aLEQThPeWSkM4q/ZqxqL3jOwDXUTeUl+JcBDYwrB9RdqFSeX2crJ1DtWHMJ cmCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zPS3FVsTO33207hcva+hc27ibn1TTf2qpiS8Pe5UWu8=; b=ilXt0HCfIi1r97o3KXiX7LYG+y5gOYhr8q9her8CB/k8pcXbDQNYOahCDTq6eUQV3U O10jj4TuiOaNcl1kePdxa7y8UyGbQkw6rkZ8RbCEW+0GtXyZJLy/uSt8NaXMUWpEOWLn jLR7vpYQtNmHKjnrLgPkwaLWArUcTzZ+Q/s318+GXMqH3jdusFNJkXlxKEtRDQPZ+6vn lPmy0B2a4bHcNnZzAFZLs1ph5LgRVC+F3p6QO3+6OMQ9q9uJq8PkXx3wOXwSQLWMXrSL X7OT95mqfrRIgcvk3kVi8xIk6dawwc+BGHoswhlPlB44AubnJhyi0N3tyOryvtg5gFZp 8Z6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Vho/La48"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e28si7372174edj.180.2020.10.19.07.34.42; Mon, 19 Oct 2020 07:35:05 -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=@gmail.com header.s=20161025 header.b="Vho/La48"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729465AbgJSOcV (ORCPT + 99 others); Mon, 19 Oct 2020 10:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728877AbgJSOcV (ORCPT ); Mon, 19 Oct 2020 10:32:21 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B19B7C0613CE; Mon, 19 Oct 2020 07:32:19 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id w7so2830251oow.7; Mon, 19 Oct 2020 07:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zPS3FVsTO33207hcva+hc27ibn1TTf2qpiS8Pe5UWu8=; b=Vho/La487lc2tSDXs9azUXYErbs/jWmRBgfHSfPpodJnmqdhTy8lG4Gn99GIUDijAB nInscWRHrO72LJZJOUfFEggpCJzLOQD5cnLwQyZkK670ykz3+RLp4tlmyKVMBWqGiSA/ AuxuOtznvZuJu7t4IvAaBvHgGK6WF7PDs/bt4Wmw29WORJ+7TK8nKXm7Y5M9mk5S+GpU brxh6Iom73s7ZRojGX4TvzAwsM1qQrUvB0Yy4d2ONGnHpIyTJPkAtrA9e7T6S8t5VkN0 pyadl7Stg4hqQJz2slAkxRaaKvyym1FsJ3+6on7ioKRxLVke2Hp4tUX8H/X59pxQyNb+ AHOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zPS3FVsTO33207hcva+hc27ibn1TTf2qpiS8Pe5UWu8=; b=DQZfjsUG4w+yqmX60qjIDOdKhpt/q4OH0Q1wXrSK/DklICyj3DL9e1EiqPx2ov9YOJ Oxup5pl077jO5ZS5gfMKnwTYb96G7nsz+HM0u3yi1XiIXYrjsC5rZbJ3uwFOLooHpIVb qtoSAiAvZIEMD0pRtTVEdwpAFg9yAROJdhRUTrdKjH0tMWEKDTDWYtSH5xggGzjx7dZL JuhUh6G2V5+y3izE7AYGuuPEr6xSrs7XnYrd2ijdjO172nXdIhp7KsGftc1N5mX/bsM9 5NCTyZVXjkkTUNHnAy3IxWy1G4FcJSUM4meTwn2nQ30TANv2T8wrKRjuAFBdPqbJD52U UpFQ== X-Gm-Message-State: AOAM533Jphdhwq11L0xlwoARQlZnZmRts3CgHO547EQhnEEzEVwoMBGb 1OG1AbMMEr6O1ycNd+t7JSUARw6dpTKCEcvuK3o= X-Received: by 2002:a4a:c3ca:: with SMTP id e10mr181026ooq.41.1603117939077; Mon, 19 Oct 2020 07:32:19 -0700 (PDT) MIME-Version: 1.0 References: <20201016055235.440159-1-allen.lkml@gmail.com> <20201016062027.GB569795@kroah.com> <20201019131613.GA3254417@kroah.com> <20201019134729.GA3259788@kroah.com> In-Reply-To: <20201019134729.GA3259788@kroah.com> From: Allen Date: Mon, 19 Oct 2020 20:02:07 +0530 Message-ID: Subject: Re: [RFC] PCI: allow sysfs file owner to read the config space with CAP_SYS_RAWIO To: Greg KH Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , ast@kernel.org, Linux Kernel Mailing List , Allen Pais , Allen Pais Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > > > 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. Okay. Thanks for the explanation. > > And just because the vfio driver "abuses" this > traditionally-debug-functionality doesn't mean you get to abuse the > permission levels either. This makes sense now. I will drop the patch. Thank you very much for the review. > > > > 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 -- - Allen