[PATCH v2 3/6] PCI/proc: Warn on writes to driver-exclusive config regions

From: Ziming Du

Date: Wed Jul 29 2026 - 23:07:30 EST


The sysfs configuration-space write path warns and taints the kernel
when userspace writes a region claimed exclusively by a driver. The
procfs path can access the same configuration space but does not perform
this check.

Add the same resource_is_exclusive() warning and taint to
proc_bus_pci_write() so the two userspace interfaces treat driver-owned
ranges consistently.

Fixes: 278294798ac9 ("PCI: Allow drivers to request exclusive config regions")
Signed-off-by: Ziming Du <duziming2@xxxxxxxxxx>
---
drivers/pci/proc.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index ec2338c1e667e..3f041765da978 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -122,6 +122,13 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
if (ret)
return ret;

+ if (resource_is_exclusive(&dev->driver_exclusive_resource, pos,
+ nbytes)) {
+ pci_warn_once(dev, "%s: Unexpected write to kernel-exclusive config offset %llx",
+ current->comm, pos);
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+ }
+
if (pos >= size)
return 0;
if (nbytes >= size)
--
2.43.0