diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/capability.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/kernel/capability.c b/kernel/capability.c index 84b2bbf443e7..a5cf13c018ce 100644 --- a/kernel/capability.c +++ b/kernel/capability.c | |||
| @@ -424,23 +424,19 @@ bool capable(int cap) | |||
| 424 | EXPORT_SYMBOL(capable); | 424 | EXPORT_SYMBOL(capable); |
| 425 | 425 | ||
| 426 | /** | 426 | /** |
| 427 | * inode_capable - Check superior capability over inode | 427 | * capable_wrt_inode_uidgid - Check nsown_capable and uid and gid mapped |
| 428 | * @inode: The inode in question | 428 | * @inode: The inode in question |
| 429 | * @cap: The capability in question | 429 | * @cap: The capability in question |
| 430 | * | 430 | * |
| 431 | * Return true if the current task has the given superior capability | 431 | * Return true if the current task has the given capability targeted at |
| 432 | * targeted at it's own user namespace and that the given inode is owned | 432 | * its own user namespace and that the given inode's uid and gid are |
| 433 | * by the current user namespace or a child namespace. | 433 | * mapped into the current user namespace. |
| 434 | * | ||
| 435 | * Currently we check to see if an inode is owned by the current | ||
| 436 | * user namespace by seeing if the inode's owner maps into the | ||
| 437 | * current user namespace. | ||
| 438 | * | ||
| 439 | */ | 434 | */ |
| 440 | bool inode_capable(const struct inode *inode, int cap) | 435 | bool capable_wrt_inode_uidgid(const struct inode *inode, int cap) |
| 441 | { | 436 | { |
| 442 | struct user_namespace *ns = current_user_ns(); | 437 | struct user_namespace *ns = current_user_ns(); |
| 443 | 438 | ||
| 444 | return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid); | 439 | return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid) && |
| 440 | kgid_has_mapping(ns, inode->i_gid); | ||
| 445 | } | 441 | } |
| 446 | EXPORT_SYMBOL(inode_capable); | 442 | EXPORT_SYMBOL(capable_wrt_inode_uidgid); |
