[PATCH 1/2] PCI: syscall: Set the ~0 value on access failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The pciconfig_read syscall has a special provision to handle users that
don't check the return value for a possible error code and rely solely
on checking for the value of ~0 to be set as a result of the PCI
configuration read failure.

The commit e4585da22ad0 ("pci syscall.c: Switch to refcounting API")
changed this semantic of setting the results to the value of ~0 to
indicate read error concerning CAP_SYS_ADMIN capability flag validation.
After this commit, the syscall would simply return -EPERM early should
the user does not have the required permissions.  This changes the
original behaviour which might not be something that the users of this
syscall expect, especially since some of the problematic users do not
check the return code whatsoever.

Thus, restore the original behaviour of setting the results to a value
of ~0 on read failure to include the capabilities check.

Fixes: e4585da22ad0 ("pci syscall.c: Switch to refcounting API")
Signed-off-by: Krzysztof Wilczyński <kw@xxxxxxxxx>
---
 drivers/pci/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
index 8b003c890b87..b842af1e06b8 100644
--- a/drivers/pci/syscall.c
+++ b/drivers/pci/syscall.c
@@ -22,8 +22,9 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
 	long err;
 	int cfg_ret;
 
+	err = -EPERM;
 	if (!capable(CAP_SYS_ADMIN))
-		return -EPERM;
+		goto error;
 
 	err = -ENODEV;
 	dev = pci_get_domain_bus_and_slot(0, bus, dfn);
-- 
2.32.0




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux