Skip to content

Commit b7e724d

Browse files
committed
capabilities: reverse arguments to security_capable
security_capable takes ns, cred, cap. But the LSM capable() hook takes cred, ns, cap. The capability helper functions also take cred, ns, cap. Rather than flip argument order just to flip it back, leave them alone. Heck, this should be a little faster since argument will be in the right place! Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 6a9de49 commit b7e724d

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/pci/pci-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pci_read_config(struct file *filp, struct kobject *kobj,
431431
u8 *data = (u8*) buf;
432432

433433
/* Several chips lock up trying to read undefined config space */
434-
if (security_capable(&init_user_ns, filp->f_cred, CAP_SYS_ADMIN) == 0) {
434+
if (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0) {
435435
size = dev->cfg_size;
436436
} else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
437437
size = 128;

include/linux/security.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ int security_capset(struct cred *new, const struct cred *old,
16661666
const kernel_cap_t *effective,
16671667
const kernel_cap_t *inheritable,
16681668
const kernel_cap_t *permitted);
1669-
int security_capable(struct user_namespace *ns, const struct cred *cred,
1669+
int security_capable(const struct cred *cred, struct user_namespace *ns,
16701670
int cap);
16711671
int security_real_capable(struct task_struct *tsk, struct user_namespace *ns,
16721672
int cap);
@@ -1863,8 +1863,8 @@ static inline int security_capset(struct cred *new,
18631863
return cap_capset(new, old, effective, inheritable, permitted);
18641864
}
18651865

1866-
static inline int security_capable(struct user_namespace *ns,
1867-
const struct cred *cred, int cap)
1866+
static inline int security_capable(const struct cred *cred,
1867+
struct user_namespace *ns, int cap)
18681868
{
18691869
return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
18701870
}

kernel/capability.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
374374
BUG();
375375
}
376376

377-
if (security_capable(ns, current_cred(), cap) == 0) {
377+
if (security_capable(current_cred(), ns, cap) == 0) {
378378
current->flags |= PF_SUPERPRIV;
379379
return true;
380380
}

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int security_capset(struct cred *new, const struct cred *old,
154154
effective, inheritable, permitted);
155155
}
156156

157-
int security_capable(struct user_namespace *ns, const struct cred *cred,
157+
int security_capable(const struct cred *cred, struct user_namespace *ns,
158158
int cap)
159159
{
160160
return security_ops->capable(cred, ns, cap, SECURITY_CAP_AUDIT);

0 commit comments

Comments
 (0)