Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3192382pxu; Mon, 19 Oct 2020 06:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs/jeo4UwXKGoxNn3UKjTGf196Vx4YRKkVgzINThsfw2S7oMIuoaILaRSDp0mhLs9QlNLA X-Received: by 2002:a17:906:8295:: with SMTP id h21mr17186212ejx.278.1603113909873; Mon, 19 Oct 2020 06:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603113909; cv=none; d=google.com; s=arc-20160816; b=a+bKlHDLrYXPgcCoVhXM3WaHK+rBSmJij5FFgIGidXxTNsQHQvyD1l9XDnBKGLSdtl 931JGD+caZyFwYNIogJr5ZmOasE3v5hlw0dDeowurvKITrYs3mougQvm/MdDop0dTW/Q v1spGfutrOyE+FOmeCU7MzSxu5SA+ajg5MRX6dxOjk1paQSOZBSwB3uT6f9ySRvd8ejQ SeeaZyZwalxrcCHvdi1eYEBv/hMen+R9f8wOZJHRLjPanNEXHR0/xEGNtI9JWid69xWn LRXzhJkQM6n6UhPfo5VpklUkNq4q27IDaLZJ8wJF1nF83CcsbvcwpDX9vG1z43PD/n4m Krbg== 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=E3Lz+f5H2qnCm4YPaUNgSzjSIKDYKn6c8ZxYUYNfS1w=; b=Ddd5Zs71B7JkLXxf1Ngx0XR35INMUQ5km7xg4Pkw1Ve7MU5+Z2+smgjcLx97YdCitX iiQ6GkYx4xySbp8tG7JwpJQc2IoHs7m7WagPgggDisY248uO9AWFu9Lr3IJSSJn03cFP HQ/eZDfp6hN5Vm8RpdaYv0fPd/lAzyy8fSJKJ8NjLUd/VMr1d4x9w9eJ78346kghOUSA D/R/5RhcqrNBELJgaGkmwQ6WFrpmRTCx+snb943nDQaNG9WEsDoNoJ2id+ktyJe2lC5y zOyxydisbg6sgH30/x6xMK9CHOo1HTKPPo5oT7l/iy6JfYdaXu8fQOP4XN6i6YaKVgBk 2KwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JFS4Spmy; 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 qc16si7538095ejb.155.2020.10.19.06.24.46; Mon, 19 Oct 2020 06:25:09 -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=JFS4Spmy; 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 S1727860AbgJSNVx (ORCPT + 99 others); Mon, 19 Oct 2020 09:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727297AbgJSNVw (ORCPT ); Mon, 19 Oct 2020 09:21:52 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABAE9C0613CE; Mon, 19 Oct 2020 06:21:51 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id u17so12347297oie.3; Mon, 19 Oct 2020 06:21:51 -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=E3Lz+f5H2qnCm4YPaUNgSzjSIKDYKn6c8ZxYUYNfS1w=; b=JFS4SpmyPt5ZOjC7dlCnr4rKUh/FWhWLlYxEQ7unXai0oPrxai1RJZlmpbxaZtjqn/ WsGr4jpeEPexCxQElREO/n28ABT1DPKZYLoqDlvKtvyQ/ZKRwW/a14TvIaEjgQzPjrIe amwUZzmIfhkqG9mdD5iBJ7dmY3T3wU1+9qXLCRNYcooTOcthVz/YDa5+ltTYvh3bd4U5 ZZldtf0fyU0QWKczckMPiuuMqQovFlOA2TXVhOl5NEES/bzIIhaTajDMlxUJTGLLdlyT wcjnk1LxwGfMwHXbMO1NGsA67qPltFCIRb3RzlJrJ2bIEVtvcOyLYf9nF9TSWeQLF5aS hq3Q== 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=E3Lz+f5H2qnCm4YPaUNgSzjSIKDYKn6c8ZxYUYNfS1w=; b=uiT1C2ZT4Q4uTes/rb9UbLjWKsm+2gPdoT0FTx0vCsKK1K2RFjKKnmrkNcaiTQwlfW xeCOxTqOqYOcLNHEhzP9F0el/CP1epdm0/CH4ikTa9z8Ai35IwdJYCZKKneILpNl4sKN ipjwwt6snEsNluE+wX4eExDSytt2S1QnPHxwN1OoJXZ6kbDIkJWuXxFuMzu/e+yNq4IA qGhAIsSILb21nPy86oU9TrTbBv5DJB5a496sUPIma9vUOXvSAnj/rM07oSDnvL0+9IIw 4q2op7vXWYucrSDjXA7MFSrsCRwafsGUx2ysRzas3k2wYzIYE/zi7DlLUTkekQrJdyDh cVfQ== X-Gm-Message-State: AOAM531JrcVM7KmNHVcKxHhOFc8aS7qVoTGDA5p84eJOwds0EqC+Q2eF 68sJMk7oW3YpWgCcFE5dAT4t14cEkyzF5m8xrDM= X-Received: by 2002:aca:4dd2:: with SMTP id a201mr10963292oib.135.1603113711085; Mon, 19 Oct 2020 06:21:51 -0700 (PDT) MIME-Version: 1.0 References: <20201016055235.440159-1-allen.lkml@gmail.com> <20201016062027.GB569795@kroah.com> <20201019131613.GA3254417@kroah.com> In-Reply-To: <20201019131613.GA3254417@kroah.com> From: Allen Date: Mon, 19 Oct 2020 18:51:39 +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. > > 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. -- - Allen