lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201016055235.440159-1-allen.lkml@gmail.com>
Date:   Fri, 16 Oct 2020 11:22:35 +0530
From:   Allen Pais <allen.lkml@...il.com>
To:     linux-pci@...r.kernel.org
Cc:     bhelgaas@...gle.com, ast@...nel.org, gregkh@...uxfoundation.org,
        linux-kernel@...r.kernel.org,
        Allen Pais <apais@...ux.microsoft.com>,
        Allen Pais <allen.pais@...l.com>
Subject: [RFC] PCI: allow sysfs file owner to read the config space with CAP_SYS_RAWIO

From: Allen Pais <apais@...ux.microsoft.com>

 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?
This patch contains a simpler fix, I would love to hear from the
Maintainers on the approach.

 The other approach that I considered was to introduce and API
which would check for multiple capabilities, something similar to
perfmon_capable()/bpf_capable(). But I could not find more users
for the API and hence dropped it.

 The problem I am trying to solve is to avoid handing out
CAP_SYS_ADMIN for extended reads of the PCI config space.

Signed-off-by: Allen Pais <allen.pais@...l.com>
---
 drivers/pci/pci-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6d78df981d41..6574c0203475 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -666,7 +666,8 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
 	u8 *data = (u8 *) buf;
 
 	/* Several chips lock up trying to read undefined config space */
-	if (file_ns_capable(filp, &init_user_ns, CAP_SYS_ADMIN))
+	if (file_ns_capable(filp, &init_user_ns, CAP_SYS_ADMIN) ||
+	    file_ns_capable(filp, &init_user_ns, CAP_SYS_RAWIO))
 		size = dev->cfg_size;
 	else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
 		size = 128;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ