pci-sysfs: use proper file capability helper function
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Apr 2016 19:00:21 +0000 (12:00 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Apr 2016 19:56:09 +0000 (12:56 -0700)
The PCI config access checked the file capabilities correctly, but used
the itnernal security capability check rather than the helper function
that is actually meant for that.

The security_capable() has unusual return values and is not meant to be
used elsewhere (the only other use is in the capability checking
functions that we actually intend people to use, and this odd PCI usage
really stood out when looking around the capability code.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/pci/pci-sysfs.c

index e982010f0ed19e0d0379da4a1c02334a1db9f175..342b6918bbde8534b0f89bade814624316a54e9d 100644 (file)
@@ -636,7 +636,7 @@ 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 (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0)
+       if (file_ns_capable(filp, &init_user_ns, CAP_SYS_ADMIN))
                size = dev->cfg_size;
        else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
                size = 128;