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  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]
Date:   Tue, 25 Jun 2019 17:36:08 -0500
From:   Bjorn Helgaas <>
To:     Greg Kroah-Hartman <>
Cc:     "Rafael J. Wysocki" <>,
        Myron Stowe <>,,
Subject: mmap/munmap in sysfs

Hi Greg, et al,

Userspace can mmap PCI device memory via the resourceN files in sysfs,
which use pci_mmap_resource().  I think this path is unaware of power
management, so the device may be runtime-suspended, e.g., it may be in
D1, D2, or D3, where it will not respond to memory accesses.

Userspace accesses while the device is suspended will cause PCI
errors, so I think we need something like the patch below.  But this
isn't sufficient by itself because we would need a corresponding
pm_runtime_put() when the mapping goes away.  Where should that go?
Or is there a better way to do this?

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6d27475e39b2..aab7a47679a7 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1173,6 +1173,7 @@ static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
 	mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
+	pm_runtime_get_sync(pdev);
 	return pci_mmap_resource_range(pdev, bar, vma, mmap_type, write_combine);

Powered by blists - more mailing lists