aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/capability.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/capability.c')
-rw-r--r--kernel/capability.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/kernel/capability.c b/kernel/capability.c
index a8d63df0c322..a5cf13c018ce 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -24,7 +24,6 @@
24 */ 24 */
25 25
26const kernel_cap_t __cap_empty_set = CAP_EMPTY_SET; 26const kernel_cap_t __cap_empty_set = CAP_EMPTY_SET;
27
28EXPORT_SYMBOL(__cap_empty_set); 27EXPORT_SYMBOL(__cap_empty_set);
29 28
30int file_caps_enabled = 1; 29int file_caps_enabled = 1;
@@ -189,7 +188,7 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
189 * 188 *
190 * An alternative would be to return an error here 189 * An alternative would be to return an error here
191 * (-ERANGE), but that causes legacy applications to 190 * (-ERANGE), but that causes legacy applications to
192 * unexpectidly fail; the capget/modify/capset aborts 191 * unexpectedly fail; the capget/modify/capset aborts
193 * before modification is attempted and the application 192 * before modification is attempted and the application
194 * fails. 193 * fails.
195 */ 194 */
@@ -395,7 +394,8 @@ EXPORT_SYMBOL(ns_capable);
395 * This does not set PF_SUPERPRIV because the caller may not 394 * This does not set PF_SUPERPRIV because the caller may not
396 * actually be privileged. 395 * actually be privileged.
397 */ 396 */
398bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap) 397bool file_ns_capable(const struct file *file, struct user_namespace *ns,
398 int cap)
399{ 399{
400 if (WARN_ON_ONCE(!cap_valid(cap))) 400 if (WARN_ON_ONCE(!cap_valid(cap)))
401 return false; 401 return false;
@@ -424,23 +424,19 @@ bool capable(int cap)
424EXPORT_SYMBOL(capable); 424EXPORT_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 */
440bool inode_capable(const struct inode *inode, int cap) 435bool 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}
446EXPORT_SYMBOL(inode_capable); 442EXPORT_SYMBOL(capable_wrt_inode_uidgid);