mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 12:52:29 -04:00
Merge branch 'pci/procfs'
- Avoid spurious runtime PM wakeup on config space accesses that are outside config space and fail before reaching PCI (Krzysztof Wilczyński) - Warn on user-space writes to kernel-exclusive config space regions, as we already do for sysfs (Krzysztof Wilczyński) - Check credentials of opener, not reader, for config space reads, as we already to for sysfs (Krzysztof Wilczyński) * pci/procfs: PCI/proc: Use file_ns_capable() when checking config space read access PCI/proc: Warn on writes to kernel-exclusive config space regions PCI/proc: Avoid spurious runtime PM wakeup on config space accesses
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#include <linux/capability.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/panic.h>
|
||||
#include <linux/sched.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include "pci.h"
|
||||
|
||||
@@ -39,13 +41,16 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
|
||||
* undefined locations (think of Intel PIIX4 as a typical example).
|
||||
*/
|
||||
|
||||
if (capable(CAP_SYS_ADMIN))
|
||||
if (file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN))
|
||||
size = dev->cfg_size;
|
||||
else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
|
||||
size = 128;
|
||||
else
|
||||
size = 64;
|
||||
|
||||
if (!nbytes)
|
||||
return 0;
|
||||
|
||||
if (pos >= size)
|
||||
return 0;
|
||||
if (nbytes >= size)
|
||||
@@ -122,6 +127,15 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!nbytes)
|
||||
return 0;
|
||||
|
||||
if (resource_is_exclusive(&dev->driver_exclusive_resource, pos, nbytes)) {
|
||||
pci_warn_once(dev, "%s: Unexpected write to kernel-exclusive config offset %x",
|
||||
current->comm, pos);
|
||||
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
|
||||
}
|
||||
|
||||
if (pos >= size)
|
||||
return 0;
|
||||
if (nbytes >= size)
|
||||
|
||||
Reference in New Issue
Block a user