blob: 6cbf41d1e77d2fe3b7ea3daf411c552c0beb4a60 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* Common capabilities, needed by capability.o.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 */
9
10#include <linux/capability.h>
11#include <linux/audit.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/lsm_hooks.h>
16#include <linux/file.h>
17#include <linux/mm.h>
18#include <linux/mman.h>
19#include <linux/pagemap.h>
20#include <linux/swap.h>
21#include <linux/skbuff.h>
22#include <linux/netlink.h>
23#include <linux/ptrace.h>
24#include <linux/xattr.h>
25#include <linux/hugetlb.h>
26#include <linux/mount.h>
27#include <linux/sched.h>
28#include <linux/prctl.h>
29#include <linux/securebits.h>
30#include <linux/user_namespace.h>
31#include <linux/binfmts.h>
32#include <linux/personality.h>
33
34#ifdef CONFIG_ANDROID_PARANOID_NETWORK
35#include <linux/android_aid.h>
36#endif
37
38/*
39 * If a non-root user executes a setuid-root binary in
40 * !secure(SECURE_NOROOT) mode, then we raise capabilities.
41 * However if fE is also set, then the intent is for only
42 * the file capabilities to be applied, and the setuid-root
43 * bit is left on either to change the uid (plausible) or
44 * to get full privilege on a kernel without file capabilities
45 * support. So in that case we do not raise capabilities.
46 *
47 * Warn if that happens, once per boot.
48 */
49static void warn_setuid_and_fcaps_mixed(const char *fname)
50{
51 static int warned;
52 if (!warned) {
53 printk(KERN_INFO "warning: `%s' has both setuid-root and"
54 " effective capabilities. Therefore not raising all"
55 " capabilities.\n", fname);
56 warned = 1;
57 }
58}
59
60/**
61 * __cap_capable - Determine whether a task has a particular effective capability
62 * @cred: The credentials to use
63 * @ns: The user namespace in which we need the capability
64 * @cap: The capability to check for
65 * @audit: Whether to write an audit message or not
66 *
67 * Determine whether the nominated task has the specified capability amongst
68 * its effective set, returning 0 if it does, -ve if it does not.
69 *
70 * NOTE WELL: cap_has_capability() cannot be used like the kernel's capable()
71 * and has_capability() functions. That is, it has the reverse semantics:
72 * cap_has_capability() returns 0 when a task has a capability, but the
73 * kernel's capable() and has_capability() returns 1 for this case.
74 */
75int __cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
76 int cap, int audit)
77{
78 struct user_namespace *ns = targ_ns;
79
80 /* See if cred has the capability in the target user namespace
81 * by examining the target user namespace and all of the target
82 * user namespace's parents.
83 */
84 for (;;) {
85 /* Do we have the necessary capabilities? */
86 if (ns == cred->user_ns)
87 return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
88
89 /*
90 * If we're already at a lower level than we're looking for,
91 * we're done searching.
92 */
93 if (ns->level <= cred->user_ns->level)
94 return -EPERM;
95
96 /*
97 * The owner of the user namespace in the parent of the
98 * user namespace has all caps.
99 */
100 if ((ns->parent == cred->user_ns) && uid_eq(ns->owner, cred->euid))
101 return 0;
102
103 /*
104 * If you have a capability in a parent user ns, then you have
105 * it over all children user namespaces as well.
106 */
107 ns = ns->parent;
108 }
109
110 /* We never get here */
111}
112
113int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
114 int cap, int audit)
115{
116 int ret = __cap_capable(cred, targ_ns, cap, audit);
117
118#ifdef CONFIG_ANDROID_PARANOID_NETWORK
119 if (ret != 0 && cap == CAP_NET_RAW && in_egroup_p(AID_NET_RAW)) {
120 printk("Process %s granted CAP_NET_RAW from Android group net_raw.\n", current->comm);
121 printk(" Please update the .rc file to explictly set 'capabilities NET_RAW'\n");
122 printk(" Implicit grants are deprecated and will be removed in the future.\n");
123 return 0;
124 }
125 if (ret != 0 && cap == CAP_NET_ADMIN && in_egroup_p(AID_NET_ADMIN)) {
126 printk("Process %s granted CAP_NET_ADMIN from Android group net_admin.\n", current->comm);
127 printk(" Please update the .rc file to explictly set 'capabilities NET_ADMIN'\n");
128 printk(" Implicit grants are deprecated and will be removed in the future.\n");
129 return 0;
130 }
131#endif
132 return ret;
133}
134/**
135 * cap_settime - Determine whether the current process may set the system clock
136 * @ts: The time to set
137 * @tz: The timezone to set
138 *
139 * Determine whether the current process may set the system clock and timezone
140 * information, returning 0 if permission granted, -ve if denied.
141 */
142int cap_settime(const struct timespec64 *ts, const struct timezone *tz)
143{
144 if (!capable(CAP_SYS_TIME))
145 return -EPERM;
146 return 0;
147}
148
149/**
150 * cap_ptrace_access_check - Determine whether the current process may access
151 * another
152 * @child: The process to be accessed
153 * @mode: The mode of attachment.
154 *
155 * If we are in the same or an ancestor user_ns and have all the target
156 * task's capabilities, then ptrace access is allowed.
157 * If we have the ptrace capability to the target user_ns, then ptrace
158 * access is allowed.
159 * Else denied.
160 *
161 * Determine whether a process may access another, returning 0 if permission
162 * granted, -ve if denied.
163 */
164int cap_ptrace_access_check(struct task_struct *child, unsigned int mode)
165{
166 int ret = 0;
167 const struct cred *cred, *child_cred;
168 const kernel_cap_t *caller_caps;
169
170 rcu_read_lock();
171 cred = current_cred();
172 child_cred = __task_cred(child);
173 if (mode & PTRACE_MODE_FSCREDS)
174 caller_caps = &cred->cap_effective;
175 else
176 caller_caps = &cred->cap_permitted;
177 if (cred->user_ns == child_cred->user_ns &&
178 cap_issubset(child_cred->cap_permitted, *caller_caps))
179 goto out;
180 if (ns_capable(child_cred->user_ns, CAP_SYS_PTRACE))
181 goto out;
182 ret = -EPERM;
183out:
184 rcu_read_unlock();
185 return ret;
186}
187
188/**
189 * cap_ptrace_traceme - Determine whether another process may trace the current
190 * @parent: The task proposed to be the tracer
191 *
192 * If parent is in the same or an ancestor user_ns and has all current's
193 * capabilities, then ptrace access is allowed.
194 * If parent has the ptrace capability to current's user_ns, then ptrace
195 * access is allowed.
196 * Else denied.
197 *
198 * Determine whether the nominated task is permitted to trace the current
199 * process, returning 0 if permission is granted, -ve if denied.
200 */
201int cap_ptrace_traceme(struct task_struct *parent)
202{
203 int ret = 0;
204 const struct cred *cred, *child_cred;
205
206 rcu_read_lock();
207 cred = __task_cred(parent);
208 child_cred = current_cred();
209 if (cred->user_ns == child_cred->user_ns &&
210 cap_issubset(child_cred->cap_permitted, cred->cap_permitted))
211 goto out;
212 if (has_ns_capability(parent, child_cred->user_ns, CAP_SYS_PTRACE))
213 goto out;
214 ret = -EPERM;
215out:
216 rcu_read_unlock();
217 return ret;
218}
219
220/**
221 * cap_capget - Retrieve a task's capability sets
222 * @target: The task from which to retrieve the capability sets
223 * @effective: The place to record the effective set
224 * @inheritable: The place to record the inheritable set
225 * @permitted: The place to record the permitted set
226 *
227 * This function retrieves the capabilities of the nominated task and returns
228 * them to the caller.
229 */
230int cap_capget(struct task_struct *target, kernel_cap_t *effective,
231 kernel_cap_t *inheritable, kernel_cap_t *permitted)
232{
233 const struct cred *cred;
234
235 /* Derived from kernel/capability.c:sys_capget. */
236 rcu_read_lock();
237 cred = __task_cred(target);
238 *effective = cred->cap_effective;
239 *inheritable = cred->cap_inheritable;
240 *permitted = cred->cap_permitted;
241 rcu_read_unlock();
242 return 0;
243}
244
245/*
246 * Determine whether the inheritable capabilities are limited to the old
247 * permitted set. Returns 1 if they are limited, 0 if they are not.
248 */
249static inline int cap_inh_is_capped(void)
250{
251
252 /* they are so limited unless the current task has the CAP_SETPCAP
253 * capability
254 */
255 if (cap_capable(current_cred(), current_cred()->user_ns,
256 CAP_SETPCAP, SECURITY_CAP_AUDIT) == 0)
257 return 0;
258 return 1;
259}
260
261/**
262 * cap_capset - Validate and apply proposed changes to current's capabilities
263 * @new: The proposed new credentials; alterations should be made here
264 * @old: The current task's current credentials
265 * @effective: A pointer to the proposed new effective capabilities set
266 * @inheritable: A pointer to the proposed new inheritable capabilities set
267 * @permitted: A pointer to the proposed new permitted capabilities set
268 *
269 * This function validates and applies a proposed mass change to the current
270 * process's capability sets. The changes are made to the proposed new
271 * credentials, and assuming no error, will be committed by the caller of LSM.
272 */
273int cap_capset(struct cred *new,
274 const struct cred *old,
275 const kernel_cap_t *effective,
276 const kernel_cap_t *inheritable,
277 const kernel_cap_t *permitted)
278{
279 if (cap_inh_is_capped() &&
280 !cap_issubset(*inheritable,
281 cap_combine(old->cap_inheritable,
282 old->cap_permitted)))
283 /* incapable of using this inheritable set */
284 return -EPERM;
285
286 if (!cap_issubset(*inheritable,
287 cap_combine(old->cap_inheritable,
288 old->cap_bset)))
289 /* no new pI capabilities outside bounding set */
290 return -EPERM;
291
292 /* verify restrictions on target's new Permitted set */
293 if (!cap_issubset(*permitted, old->cap_permitted))
294 return -EPERM;
295
296 /* verify the _new_Effective_ is a subset of the _new_Permitted_ */
297 if (!cap_issubset(*effective, *permitted))
298 return -EPERM;
299
300 new->cap_effective = *effective;
301 new->cap_inheritable = *inheritable;
302 new->cap_permitted = *permitted;
303
304 /*
305 * Mask off ambient bits that are no longer both permitted and
306 * inheritable.
307 */
308 new->cap_ambient = cap_intersect(new->cap_ambient,
309 cap_intersect(*permitted,
310 *inheritable));
311 if (WARN_ON(!cap_ambient_invariant_ok(new)))
312 return -EINVAL;
313 return 0;
314}
315
316/**
317 * cap_inode_need_killpriv - Determine if inode change affects privileges
318 * @dentry: The inode/dentry in being changed with change marked ATTR_KILL_PRIV
319 *
320 * Determine if an inode having a change applied that's marked ATTR_KILL_PRIV
321 * affects the security markings on that inode, and if it is, should
322 * inode_killpriv() be invoked or the change rejected.
323 *
324 * Returns 1 if security.capability has a value, meaning inode_killpriv()
325 * is required, 0 otherwise, meaning inode_killpriv() is not required.
326 */
327int cap_inode_need_killpriv(struct dentry *dentry)
328{
329 struct inode *inode = d_backing_inode(dentry);
330 int error;
331
332 error = __vfs_getxattr(dentry, inode, XATTR_NAME_CAPS, NULL, 0);
333 return error > 0;
334}
335
336/**
337 * cap_inode_killpriv - Erase the security markings on an inode
338 * @dentry: The inode/dentry to alter
339 *
340 * Erase the privilege-enhancing security markings on an inode.
341 *
342 * Returns 0 if successful, -ve on error.
343 */
344int cap_inode_killpriv(struct dentry *dentry)
345{
346 int error;
347
348 error = __vfs_removexattr(dentry, XATTR_NAME_CAPS);
349 if (error == -EOPNOTSUPP)
350 error = 0;
351 return error;
352}
353
354static bool rootid_owns_currentns(kuid_t kroot)
355{
356 struct user_namespace *ns;
357
358 if (!uid_valid(kroot))
359 return false;
360
361 for (ns = current_user_ns(); ; ns = ns->parent) {
362 if (from_kuid(ns, kroot) == 0)
363 return true;
364 if (ns == &init_user_ns)
365 break;
366 }
367
368 return false;
369}
370
371static __u32 sansflags(__u32 m)
372{
373 return m & ~VFS_CAP_FLAGS_EFFECTIVE;
374}
375
376static bool is_v2header(size_t size, const struct vfs_cap_data *cap)
377{
378 if (size != XATTR_CAPS_SZ_2)
379 return false;
380 return sansflags(le32_to_cpu(cap->magic_etc)) == VFS_CAP_REVISION_2;
381}
382
383static bool is_v3header(size_t size, const struct vfs_cap_data *cap)
384{
385 if (size != XATTR_CAPS_SZ_3)
386 return false;
387 return sansflags(le32_to_cpu(cap->magic_etc)) == VFS_CAP_REVISION_3;
388}
389
390/*
391 * getsecurity: We are called for security.* before any attempt to read the
392 * xattr from the inode itself.
393 *
394 * This gives us a chance to read the on-disk value and convert it. If we
395 * return -EOPNOTSUPP, then vfs_getxattr() will call the i_op handler.
396 *
397 * Note we are not called by vfs_getxattr_alloc(), but that is only called
398 * by the integrity subsystem, which really wants the unconverted values -
399 * so that's good.
400 */
401int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer,
402 bool alloc)
403{
404 int size, ret;
405 kuid_t kroot;
406 uid_t root, mappedroot;
407 char *tmpbuf = NULL;
408 struct vfs_cap_data *cap;
409 struct vfs_ns_cap_data *nscap;
410 struct dentry *dentry;
411 struct user_namespace *fs_ns;
412
413 if (strcmp(name, "capability") != 0)
414 return -EOPNOTSUPP;
415
416 dentry = d_find_any_alias(inode);
417 if (!dentry)
418 return -EINVAL;
419
420 size = sizeof(struct vfs_ns_cap_data);
421 ret = (int) vfs_getxattr_alloc(dentry, XATTR_NAME_CAPS,
422 &tmpbuf, size, GFP_NOFS);
423 dput(dentry);
424
425 if (ret < 0)
426 return ret;
427
428 fs_ns = inode->i_sb->s_user_ns;
429 cap = (struct vfs_cap_data *) tmpbuf;
430 if (is_v2header((size_t) ret, cap)) {
431 /* If this is sizeof(vfs_cap_data) then we're ok with the
432 * on-disk value, so return that. */
433 if (alloc)
434 *buffer = tmpbuf;
435 else
436 kfree(tmpbuf);
437 return ret;
438 } else if (!is_v3header((size_t) ret, cap)) {
439 kfree(tmpbuf);
440 return -EINVAL;
441 }
442
443 nscap = (struct vfs_ns_cap_data *) tmpbuf;
444 root = le32_to_cpu(nscap->rootid);
445 kroot = make_kuid(fs_ns, root);
446
447 /* If the root kuid maps to a valid uid in current ns, then return
448 * this as a nscap. */
449 mappedroot = from_kuid(current_user_ns(), kroot);
450 if (mappedroot != (uid_t)-1 && mappedroot != (uid_t)0) {
451 if (alloc) {
452 *buffer = tmpbuf;
453 nscap->rootid = cpu_to_le32(mappedroot);
454 } else
455 kfree(tmpbuf);
456 return size;
457 }
458
459 if (!rootid_owns_currentns(kroot)) {
460 kfree(tmpbuf);
461 return -EOPNOTSUPP;
462 }
463
464 /* This comes from a parent namespace. Return as a v2 capability */
465 size = sizeof(struct vfs_cap_data);
466 if (alloc) {
467 *buffer = kmalloc(size, GFP_ATOMIC);
468 if (*buffer) {
469 struct vfs_cap_data *cap = *buffer;
470 __le32 nsmagic, magic;
471 magic = VFS_CAP_REVISION_2;
472 nsmagic = le32_to_cpu(nscap->magic_etc);
473 if (nsmagic & VFS_CAP_FLAGS_EFFECTIVE)
474 magic |= VFS_CAP_FLAGS_EFFECTIVE;
475 memcpy(&cap->data, &nscap->data, sizeof(__le32) * 2 * VFS_CAP_U32);
476 cap->magic_etc = cpu_to_le32(magic);
477 } else {
478 size = -ENOMEM;
479 }
480 }
481 kfree(tmpbuf);
482 return size;
483}
484
485static kuid_t rootid_from_xattr(const void *value, size_t size,
486 struct user_namespace *task_ns)
487{
488 const struct vfs_ns_cap_data *nscap = value;
489 uid_t rootid = 0;
490
491 if (size == XATTR_CAPS_SZ_3)
492 rootid = le32_to_cpu(nscap->rootid);
493
494 return make_kuid(task_ns, rootid);
495}
496
497static bool validheader(size_t size, const struct vfs_cap_data *cap)
498{
499 return is_v2header(size, cap) || is_v3header(size, cap);
500}
501
502/*
503 * User requested a write of security.capability. If needed, update the
504 * xattr to change from v2 to v3, or to fixup the v3 rootid.
505 *
506 * If all is ok, we return the new size, on error return < 0.
507 */
508int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size)
509{
510 struct vfs_ns_cap_data *nscap;
511 uid_t nsrootid;
512 const struct vfs_cap_data *cap = *ivalue;
513 __u32 magic, nsmagic;
514 struct inode *inode = d_backing_inode(dentry);
515 struct user_namespace *task_ns = current_user_ns(),
516 *fs_ns = inode->i_sb->s_user_ns;
517 kuid_t rootid;
518 size_t newsize;
519
520 if (!*ivalue)
521 return -EINVAL;
522 if (!validheader(size, cap))
523 return -EINVAL;
524 if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP))
525 return -EPERM;
526 if (size == XATTR_CAPS_SZ_2)
527 if (ns_capable(inode->i_sb->s_user_ns, CAP_SETFCAP))
528 /* user is privileged, just write the v2 */
529 return size;
530
531 rootid = rootid_from_xattr(*ivalue, size, task_ns);
532 if (!uid_valid(rootid))
533 return -EINVAL;
534
535 nsrootid = from_kuid(fs_ns, rootid);
536 if (nsrootid == -1)
537 return -EINVAL;
538
539 newsize = sizeof(struct vfs_ns_cap_data);
540 nscap = kmalloc(newsize, GFP_ATOMIC);
541 if (!nscap)
542 return -ENOMEM;
543 nscap->rootid = cpu_to_le32(nsrootid);
544 nsmagic = VFS_CAP_REVISION_3;
545 magic = le32_to_cpu(cap->magic_etc);
546 if (magic & VFS_CAP_FLAGS_EFFECTIVE)
547 nsmagic |= VFS_CAP_FLAGS_EFFECTIVE;
548 nscap->magic_etc = cpu_to_le32(nsmagic);
549 memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32);
550
551 kvfree(*ivalue);
552 *ivalue = nscap;
553 return newsize;
554}
555
556/*
557 * Calculate the new process capability sets from the capability sets attached
558 * to a file.
559 */
560static inline int bprm_caps_from_vfs_caps(struct cpu_vfs_cap_data *caps,
561 struct linux_binprm *bprm,
562 bool *effective,
563 bool *has_cap)
564{
565 struct cred *new = bprm->cred;
566 unsigned i;
567 int ret = 0;
568
569 if (caps->magic_etc & VFS_CAP_FLAGS_EFFECTIVE)
570 *effective = true;
571
572 if (caps->magic_etc & VFS_CAP_REVISION_MASK)
573 *has_cap = true;
574
575 CAP_FOR_EACH_U32(i) {
576 __u32 permitted = caps->permitted.cap[i];
577 __u32 inheritable = caps->inheritable.cap[i];
578
579 /*
580 * pP' = (X & fP) | (pI & fI)
581 * The addition of pA' is handled later.
582 */
583 new->cap_permitted.cap[i] =
584 (new->cap_bset.cap[i] & permitted) |
585 (new->cap_inheritable.cap[i] & inheritable);
586
587 if (permitted & ~new->cap_permitted.cap[i])
588 /* insufficient to execute correctly */
589 ret = -EPERM;
590 }
591
592 /*
593 * For legacy apps, with no internal support for recognizing they
594 * do not have enough capabilities, we return an error if they are
595 * missing some "forced" (aka file-permitted) capabilities.
596 */
597 return *effective ? ret : 0;
598}
599
600/*
601 * Extract the on-exec-apply capability sets for an executable file.
602 */
603int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps)
604{
605 struct inode *inode = d_backing_inode(dentry);
606 __u32 magic_etc;
607 unsigned tocopy, i;
608 int size;
609 struct vfs_ns_cap_data data, *nscaps = &data;
610 struct vfs_cap_data *caps = (struct vfs_cap_data *) &data;
611 kuid_t rootkuid;
612 struct user_namespace *fs_ns;
613
614 memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
615
616 if (!inode)
617 return -ENODATA;
618
619 fs_ns = inode->i_sb->s_user_ns;
620 size = __vfs_getxattr((struct dentry *)dentry, inode,
621 XATTR_NAME_CAPS, &data, XATTR_CAPS_SZ);
622 if (size == -ENODATA || size == -EOPNOTSUPP)
623 /* no data, that's ok */
624 return -ENODATA;
625
626 if (size < 0)
627 return size;
628
629 if (size < sizeof(magic_etc))
630 return -EINVAL;
631
632 cpu_caps->magic_etc = magic_etc = le32_to_cpu(caps->magic_etc);
633
634 rootkuid = make_kuid(fs_ns, 0);
635 switch (magic_etc & VFS_CAP_REVISION_MASK) {
636 case VFS_CAP_REVISION_1:
637 if (size != XATTR_CAPS_SZ_1)
638 return -EINVAL;
639 tocopy = VFS_CAP_U32_1;
640 break;
641 case VFS_CAP_REVISION_2:
642 if (size != XATTR_CAPS_SZ_2)
643 return -EINVAL;
644 tocopy = VFS_CAP_U32_2;
645 break;
646 case VFS_CAP_REVISION_3:
647 if (size != XATTR_CAPS_SZ_3)
648 return -EINVAL;
649 tocopy = VFS_CAP_U32_3;
650 rootkuid = make_kuid(fs_ns, le32_to_cpu(nscaps->rootid));
651 break;
652
653 default:
654 return -EINVAL;
655 }
656 /* Limit the caps to the mounter of the filesystem
657 * or the more limited uid specified in the xattr.
658 */
659 if (!rootid_owns_currentns(rootkuid))
660 return -ENODATA;
661
662 CAP_FOR_EACH_U32(i) {
663 if (i >= tocopy)
664 break;
665 cpu_caps->permitted.cap[i] = le32_to_cpu(caps->data[i].permitted);
666 cpu_caps->inheritable.cap[i] = le32_to_cpu(caps->data[i].inheritable);
667 }
668
669 cpu_caps->permitted.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
670 cpu_caps->inheritable.cap[CAP_LAST_U32] &= CAP_LAST_U32_VALID_MASK;
671
672 return 0;
673}
674
675/*
676 * Attempt to get the on-exec apply capability sets for an executable file from
677 * its xattrs and, if present, apply them to the proposed credentials being
678 * constructed by execve().
679 */
680static int get_file_caps(struct linux_binprm *bprm, bool *effective, bool *has_cap)
681{
682 int rc = 0;
683 struct cpu_vfs_cap_data vcaps;
684
685 cap_clear(bprm->cred->cap_permitted);
686
687 if (!file_caps_enabled)
688 return 0;
689
690 if (!mnt_may_suid(bprm->file->f_path.mnt))
691 return 0;
692
693 /*
694 * This check is redundant with mnt_may_suid() but is kept to make
695 * explicit that capability bits are limited to s_user_ns and its
696 * descendants.
697 */
698 if (!current_in_userns(bprm->file->f_path.mnt->mnt_sb->s_user_ns))
699 return 0;
700
701 rc = get_vfs_caps_from_disk(bprm->file->f_path.dentry, &vcaps);
702 if (rc < 0) {
703 if (rc == -EINVAL)
704 printk(KERN_NOTICE "Invalid argument reading file caps for %s\n",
705 bprm->filename);
706 else if (rc == -ENODATA)
707 rc = 0;
708 goto out;
709 }
710
711 rc = bprm_caps_from_vfs_caps(&vcaps, bprm, effective, has_cap);
712 if (rc == -EINVAL)
713 printk(KERN_NOTICE "%s: cap_from_disk returned %d for %s\n",
714 __func__, rc, bprm->filename);
715
716out:
717 if (rc)
718 cap_clear(bprm->cred->cap_permitted);
719
720 return rc;
721}
722
723/**
724 * cap_bprm_set_creds - Set up the proposed credentials for execve().
725 * @bprm: The execution parameters, including the proposed creds
726 *
727 * Set up the proposed credentials for a new execution context being
728 * constructed by execve(). The proposed creds in @bprm->cred is altered,
729 * which won't take effect immediately. Returns 0 if successful, -ve on error.
730 */
731int cap_bprm_set_creds(struct linux_binprm *bprm)
732{
733 const struct cred *old = current_cred();
734 struct cred *new = bprm->cred;
735 bool effective, has_cap = false, is_setid;
736 int ret;
737 kuid_t root_uid;
738
739 new->cap_ambient = old->cap_ambient;
740 if (WARN_ON(!cap_ambient_invariant_ok(old)))
741 return -EPERM;
742
743 effective = false;
744 ret = get_file_caps(bprm, &effective, &has_cap);
745 if (ret < 0)
746 return ret;
747
748 root_uid = make_kuid(new->user_ns, 0);
749
750 if (!issecure(SECURE_NOROOT)) {
751 /*
752 * If the legacy file capability is set, then don't set privs
753 * for a setuid root binary run by a non-root user. Do set it
754 * for a root user just to cause least surprise to an admin.
755 */
756 if (has_cap && !uid_eq(new->uid, root_uid) && uid_eq(new->euid, root_uid)) {
757 warn_setuid_and_fcaps_mixed(bprm->filename);
758 goto skip;
759 }
760 /*
761 * To support inheritance of root-permissions and suid-root
762 * executables under compatibility mode, we override the
763 * capability sets for the file.
764 *
765 * If only the real uid is 0, we do not set the effective bit.
766 */
767 if (uid_eq(new->euid, root_uid) || uid_eq(new->uid, root_uid)) {
768 /* pP' = (cap_bset & ~0) | (pI & ~0) */
769 new->cap_permitted = cap_combine(old->cap_bset,
770 old->cap_inheritable);
771 }
772 if (uid_eq(new->euid, root_uid))
773 effective = true;
774 }
775skip:
776
777 /* if we have fs caps, clear dangerous personality flags */
778 if (!cap_issubset(new->cap_permitted, old->cap_permitted))
779 bprm->per_clear |= PER_CLEAR_ON_SETID;
780
781
782 /* Don't let someone trace a set[ug]id/setpcap binary with the revised
783 * credentials unless they have the appropriate permit.
784 *
785 * In addition, if NO_NEW_PRIVS, then ensure we get no new privs.
786 */
787 is_setid = !uid_eq(new->euid, old->uid) || !gid_eq(new->egid, old->gid);
788
789 if ((is_setid ||
790 !cap_issubset(new->cap_permitted, old->cap_permitted)) &&
791 ((bprm->unsafe & ~LSM_UNSAFE_PTRACE) ||
792 !ptracer_capable(current, new->user_ns))) {
793 /* downgrade; they get no more than they had, and maybe less */
794 if (!ns_capable(new->user_ns, CAP_SETUID) ||
795 (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS)) {
796 new->euid = new->uid;
797 new->egid = new->gid;
798 }
799 new->cap_permitted = cap_intersect(new->cap_permitted,
800 old->cap_permitted);
801 }
802
803 new->suid = new->fsuid = new->euid;
804 new->sgid = new->fsgid = new->egid;
805
806 /* File caps or setid cancels ambient. */
807 if (has_cap || is_setid)
808 cap_clear(new->cap_ambient);
809
810 /*
811 * Now that we've computed pA', update pP' to give:
812 * pP' = (X & fP) | (pI & fI) | pA'
813 */
814 new->cap_permitted = cap_combine(new->cap_permitted, new->cap_ambient);
815
816 /*
817 * Set pE' = (fE ? pP' : pA'). Because pA' is zero if fE is set,
818 * this is the same as pE' = (fE ? pP' : 0) | pA'.
819 */
820 if (effective)
821 new->cap_effective = new->cap_permitted;
822 else
823 new->cap_effective = new->cap_ambient;
824
825 if (WARN_ON(!cap_ambient_invariant_ok(new)))
826 return -EPERM;
827
828 /*
829 * Audit candidate if current->cap_effective is set
830 *
831 * We do not bother to audit if 3 things are true:
832 * 1) cap_effective has all caps
833 * 2) we are root
834 * 3) root is supposed to have all caps (SECURE_NOROOT)
835 * Since this is just a normal root execing a process.
836 *
837 * Number 1 above might fail if you don't have a full bset, but I think
838 * that is interesting information to audit.
839 */
840 if (!cap_issubset(new->cap_effective, new->cap_ambient)) {
841 if (!cap_issubset(CAP_FULL_SET, new->cap_effective) ||
842 !uid_eq(new->euid, root_uid) || !uid_eq(new->uid, root_uid) ||
843 issecure(SECURE_NOROOT)) {
844 ret = audit_log_bprm_fcaps(bprm, new, old);
845 if (ret < 0)
846 return ret;
847 }
848 }
849
850 new->securebits &= ~issecure_mask(SECURE_KEEP_CAPS);
851
852 if (WARN_ON(!cap_ambient_invariant_ok(new)))
853 return -EPERM;
854
855 /* Check for privilege-elevated exec. */
856 bprm->cap_elevated = 0;
857 if (is_setid) {
858 bprm->cap_elevated = 1;
859 } else if (!uid_eq(new->uid, root_uid)) {
860 if (effective ||
861 !cap_issubset(new->cap_permitted, new->cap_ambient))
862 bprm->cap_elevated = 1;
863 }
864
865 return 0;
866}
867
868/**
869 * cap_inode_setxattr - Determine whether an xattr may be altered
870 * @dentry: The inode/dentry being altered
871 * @name: The name of the xattr to be changed
872 * @value: The value that the xattr will be changed to
873 * @size: The size of value
874 * @flags: The replacement flag
875 *
876 * Determine whether an xattr may be altered or set on an inode, returning 0 if
877 * permission is granted, -ve if denied.
878 *
879 * This is used to make sure security xattrs don't get updated or set by those
880 * who aren't privileged to do so.
881 */
882int cap_inode_setxattr(struct dentry *dentry, const char *name,
883 const void *value, size_t size, int flags)
884{
885 /* Ignore non-security xattrs */
886 if (strncmp(name, XATTR_SECURITY_PREFIX,
887 sizeof(XATTR_SECURITY_PREFIX) - 1) != 0)
888 return 0;
889
890 /*
891 * For XATTR_NAME_CAPS the check will be done in
892 * cap_convert_nscap(), called by setxattr()
893 */
894 if (strcmp(name, XATTR_NAME_CAPS) == 0)
895 return 0;
896
897 if (!capable(CAP_SYS_ADMIN))
898 return -EPERM;
899 return 0;
900}
901
902/**
903 * cap_inode_removexattr - Determine whether an xattr may be removed
904 * @dentry: The inode/dentry being altered
905 * @name: The name of the xattr to be changed
906 *
907 * Determine whether an xattr may be removed from an inode, returning 0 if
908 * permission is granted, -ve if denied.
909 *
910 * This is used to make sure security xattrs don't get removed by those who
911 * aren't privileged to remove them.
912 */
913int cap_inode_removexattr(struct dentry *dentry, const char *name)
914{
915 /* Ignore non-security xattrs */
916 if (strncmp(name, XATTR_SECURITY_PREFIX,
917 sizeof(XATTR_SECURITY_PREFIX) - 1) != 0)
918 return 0;
919
920 if (strcmp(name, XATTR_NAME_CAPS) == 0) {
921 /* security.capability gets namespaced */
922 struct inode *inode = d_backing_inode(dentry);
923 if (!inode)
924 return -EINVAL;
925 if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP))
926 return -EPERM;
927 return 0;
928 }
929
930 if (!capable(CAP_SYS_ADMIN))
931 return -EPERM;
932 return 0;
933}
934
935/*
936 * cap_emulate_setxuid() fixes the effective / permitted capabilities of
937 * a process after a call to setuid, setreuid, or setresuid.
938 *
939 * 1) When set*uiding _from_ one of {r,e,s}uid == 0 _to_ all of
940 * {r,e,s}uid != 0, the permitted and effective capabilities are
941 * cleared.
942 *
943 * 2) When set*uiding _from_ euid == 0 _to_ euid != 0, the effective
944 * capabilities of the process are cleared.
945 *
946 * 3) When set*uiding _from_ euid != 0 _to_ euid == 0, the effective
947 * capabilities are set to the permitted capabilities.
948 *
949 * fsuid is handled elsewhere. fsuid == 0 and {r,e,s}uid!= 0 should
950 * never happen.
951 *
952 * -astor
953 *
954 * cevans - New behaviour, Oct '99
955 * A process may, via prctl(), elect to keep its capabilities when it
956 * calls setuid() and switches away from uid==0. Both permitted and
957 * effective sets will be retained.
958 * Without this change, it was impossible for a daemon to drop only some
959 * of its privilege. The call to setuid(!=0) would drop all privileges!
960 * Keeping uid 0 is not an option because uid 0 owns too many vital
961 * files..
962 * Thanks to Olaf Kirch and Peter Benie for spotting this.
963 */
964static inline void cap_emulate_setxuid(struct cred *new, const struct cred *old)
965{
966 kuid_t root_uid = make_kuid(old->user_ns, 0);
967
968 if ((uid_eq(old->uid, root_uid) ||
969 uid_eq(old->euid, root_uid) ||
970 uid_eq(old->suid, root_uid)) &&
971 (!uid_eq(new->uid, root_uid) &&
972 !uid_eq(new->euid, root_uid) &&
973 !uid_eq(new->suid, root_uid))) {
974 if (!issecure(SECURE_KEEP_CAPS)) {
975 cap_clear(new->cap_permitted);
976 cap_clear(new->cap_effective);
977 }
978
979 /*
980 * Pre-ambient programs expect setresuid to nonroot followed
981 * by exec to drop capabilities. We should make sure that
982 * this remains the case.
983 */
984 cap_clear(new->cap_ambient);
985 }
986 if (uid_eq(old->euid, root_uid) && !uid_eq(new->euid, root_uid))
987 cap_clear(new->cap_effective);
988 if (!uid_eq(old->euid, root_uid) && uid_eq(new->euid, root_uid))
989 new->cap_effective = new->cap_permitted;
990}
991
992/**
993 * cap_task_fix_setuid - Fix up the results of setuid() call
994 * @new: The proposed credentials
995 * @old: The current task's current credentials
996 * @flags: Indications of what has changed
997 *
998 * Fix up the results of setuid() call before the credential changes are
999 * actually applied, returning 0 to grant the changes, -ve to deny them.
1000 */
1001int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags)
1002{
1003 switch (flags) {
1004 case LSM_SETID_RE:
1005 case LSM_SETID_ID:
1006 case LSM_SETID_RES:
1007 /* juggle the capabilities to follow [RES]UID changes unless
1008 * otherwise suppressed */
1009 if (!issecure(SECURE_NO_SETUID_FIXUP))
1010 cap_emulate_setxuid(new, old);
1011 break;
1012
1013 case LSM_SETID_FS:
1014 /* juggle the capabilties to follow FSUID changes, unless
1015 * otherwise suppressed
1016 *
1017 * FIXME - is fsuser used for all CAP_FS_MASK capabilities?
1018 * if not, we might be a bit too harsh here.
1019 */
1020 if (!issecure(SECURE_NO_SETUID_FIXUP)) {
1021 kuid_t root_uid = make_kuid(old->user_ns, 0);
1022 if (uid_eq(old->fsuid, root_uid) && !uid_eq(new->fsuid, root_uid))
1023 new->cap_effective =
1024 cap_drop_fs_set(new->cap_effective);
1025
1026 if (!uid_eq(old->fsuid, root_uid) && uid_eq(new->fsuid, root_uid))
1027 new->cap_effective =
1028 cap_raise_fs_set(new->cap_effective,
1029 new->cap_permitted);
1030 }
1031 break;
1032
1033 default:
1034 return -EINVAL;
1035 }
1036
1037 return 0;
1038}
1039
1040/*
1041 * Rationale: code calling task_setscheduler, task_setioprio, and
1042 * task_setnice, assumes that
1043 * . if capable(cap_sys_nice), then those actions should be allowed
1044 * . if not capable(cap_sys_nice), but acting on your own processes,
1045 * then those actions should be allowed
1046 * This is insufficient now since you can call code without suid, but
1047 * yet with increased caps.
1048 * So we check for increased caps on the target process.
1049 */
1050static int cap_safe_nice(struct task_struct *p)
1051{
1052 int is_subset, ret = 0;
1053
1054 rcu_read_lock();
1055 is_subset = cap_issubset(__task_cred(p)->cap_permitted,
1056 current_cred()->cap_permitted);
1057 if (!is_subset && !ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE))
1058 ret = -EPERM;
1059 rcu_read_unlock();
1060
1061 return ret;
1062}
1063
1064/**
1065 * cap_task_setscheduler - Detemine if scheduler policy change is permitted
1066 * @p: The task to affect
1067 *
1068 * Detemine if the requested scheduler policy change is permitted for the
1069 * specified task, returning 0 if permission is granted, -ve if denied.
1070 */
1071int cap_task_setscheduler(struct task_struct *p)
1072{
1073 return cap_safe_nice(p);
1074}
1075
1076/**
1077 * cap_task_ioprio - Detemine if I/O priority change is permitted
1078 * @p: The task to affect
1079 * @ioprio: The I/O priority to set
1080 *
1081 * Detemine if the requested I/O priority change is permitted for the specified
1082 * task, returning 0 if permission is granted, -ve if denied.
1083 */
1084int cap_task_setioprio(struct task_struct *p, int ioprio)
1085{
1086 return cap_safe_nice(p);
1087}
1088
1089/**
1090 * cap_task_ioprio - Detemine if task priority change is permitted
1091 * @p: The task to affect
1092 * @nice: The nice value to set
1093 *
1094 * Detemine if the requested task priority change is permitted for the
1095 * specified task, returning 0 if permission is granted, -ve if denied.
1096 */
1097int cap_task_setnice(struct task_struct *p, int nice)
1098{
1099 return cap_safe_nice(p);
1100}
1101
1102/*
1103 * Implement PR_CAPBSET_DROP. Attempt to remove the specified capability from
1104 * the current task's bounding set. Returns 0 on success, -ve on error.
1105 */
1106static int cap_prctl_drop(unsigned long cap)
1107{
1108 struct cred *new;
1109
1110 if (!ns_capable(current_user_ns(), CAP_SETPCAP))
1111 return -EPERM;
1112 if (!cap_valid(cap))
1113 return -EINVAL;
1114
1115 new = prepare_creds();
1116 if (!new)
1117 return -ENOMEM;
1118 cap_lower(new->cap_bset, cap);
1119 return commit_creds(new);
1120}
1121
1122/**
1123 * cap_task_prctl - Implement process control functions for this security module
1124 * @option: The process control function requested
1125 * @arg2, @arg3, @arg4, @arg5: The argument data for this function
1126 *
1127 * Allow process control functions (sys_prctl()) to alter capabilities; may
1128 * also deny access to other functions not otherwise implemented here.
1129 *
1130 * Returns 0 or +ve on success, -ENOSYS if this function is not implemented
1131 * here, other -ve on error. If -ENOSYS is returned, sys_prctl() and other LSM
1132 * modules will consider performing the function.
1133 */
1134int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1135 unsigned long arg4, unsigned long arg5)
1136{
1137 const struct cred *old = current_cred();
1138 struct cred *new;
1139
1140 switch (option) {
1141 case PR_CAPBSET_READ:
1142 if (!cap_valid(arg2))
1143 return -EINVAL;
1144 return !!cap_raised(old->cap_bset, arg2);
1145
1146 case PR_CAPBSET_DROP:
1147 return cap_prctl_drop(arg2);
1148
1149 /*
1150 * The next four prctl's remain to assist with transitioning a
1151 * system from legacy UID=0 based privilege (when filesystem
1152 * capabilities are not in use) to a system using filesystem
1153 * capabilities only - as the POSIX.1e draft intended.
1154 *
1155 * Note:
1156 *
1157 * PR_SET_SECUREBITS =
1158 * issecure_mask(SECURE_KEEP_CAPS_LOCKED)
1159 * | issecure_mask(SECURE_NOROOT)
1160 * | issecure_mask(SECURE_NOROOT_LOCKED)
1161 * | issecure_mask(SECURE_NO_SETUID_FIXUP)
1162 * | issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED)
1163 *
1164 * will ensure that the current process and all of its
1165 * children will be locked into a pure
1166 * capability-based-privilege environment.
1167 */
1168 case PR_SET_SECUREBITS:
1169 if ((((old->securebits & SECURE_ALL_LOCKS) >> 1)
1170 & (old->securebits ^ arg2)) /*[1]*/
1171 || ((old->securebits & SECURE_ALL_LOCKS & ~arg2)) /*[2]*/
1172 || (arg2 & ~(SECURE_ALL_LOCKS | SECURE_ALL_BITS)) /*[3]*/
1173 || (cap_capable(current_cred(),
1174 current_cred()->user_ns, CAP_SETPCAP,
1175 SECURITY_CAP_AUDIT) != 0) /*[4]*/
1176 /*
1177 * [1] no changing of bits that are locked
1178 * [2] no unlocking of locks
1179 * [3] no setting of unsupported bits
1180 * [4] doing anything requires privilege (go read about
1181 * the "sendmail capabilities bug")
1182 */
1183 )
1184 /* cannot change a locked bit */
1185 return -EPERM;
1186
1187 new = prepare_creds();
1188 if (!new)
1189 return -ENOMEM;
1190 new->securebits = arg2;
1191 return commit_creds(new);
1192
1193 case PR_GET_SECUREBITS:
1194 return old->securebits;
1195
1196 case PR_GET_KEEPCAPS:
1197 return !!issecure(SECURE_KEEP_CAPS);
1198
1199 case PR_SET_KEEPCAPS:
1200 if (arg2 > 1) /* Note, we rely on arg2 being unsigned here */
1201 return -EINVAL;
1202 if (issecure(SECURE_KEEP_CAPS_LOCKED))
1203 return -EPERM;
1204
1205 new = prepare_creds();
1206 if (!new)
1207 return -ENOMEM;
1208 if (arg2)
1209 new->securebits |= issecure_mask(SECURE_KEEP_CAPS);
1210 else
1211 new->securebits &= ~issecure_mask(SECURE_KEEP_CAPS);
1212 return commit_creds(new);
1213
1214 case PR_CAP_AMBIENT:
1215 if (arg2 == PR_CAP_AMBIENT_CLEAR_ALL) {
1216 if (arg3 | arg4 | arg5)
1217 return -EINVAL;
1218
1219 new = prepare_creds();
1220 if (!new)
1221 return -ENOMEM;
1222 cap_clear(new->cap_ambient);
1223 return commit_creds(new);
1224 }
1225
1226 if (((!cap_valid(arg3)) | arg4 | arg5))
1227 return -EINVAL;
1228
1229 if (arg2 == PR_CAP_AMBIENT_IS_SET) {
1230 return !!cap_raised(current_cred()->cap_ambient, arg3);
1231 } else if (arg2 != PR_CAP_AMBIENT_RAISE &&
1232 arg2 != PR_CAP_AMBIENT_LOWER) {
1233 return -EINVAL;
1234 } else {
1235 if (arg2 == PR_CAP_AMBIENT_RAISE &&
1236 (!cap_raised(current_cred()->cap_permitted, arg3) ||
1237 !cap_raised(current_cred()->cap_inheritable,
1238 arg3) ||
1239 issecure(SECURE_NO_CAP_AMBIENT_RAISE)))
1240 return -EPERM;
1241
1242 new = prepare_creds();
1243 if (!new)
1244 return -ENOMEM;
1245 if (arg2 == PR_CAP_AMBIENT_RAISE)
1246 cap_raise(new->cap_ambient, arg3);
1247 else
1248 cap_lower(new->cap_ambient, arg3);
1249 return commit_creds(new);
1250 }
1251
1252 default:
1253 /* No functionality available - continue with default */
1254 return -ENOSYS;
1255 }
1256}
1257
1258/**
1259 * cap_vm_enough_memory - Determine whether a new virtual mapping is permitted
1260 * @mm: The VM space in which the new mapping is to be made
1261 * @pages: The size of the mapping
1262 *
1263 * Determine whether the allocation of a new virtual mapping by the current
1264 * task is permitted, returning 1 if permission is granted, 0 if not.
1265 */
1266int cap_vm_enough_memory(struct mm_struct *mm, long pages)
1267{
1268 int cap_sys_admin = 0;
1269
1270 if (cap_capable(current_cred(), &init_user_ns, CAP_SYS_ADMIN,
1271 SECURITY_CAP_NOAUDIT) == 0)
1272 cap_sys_admin = 1;
1273 return cap_sys_admin;
1274}
1275
1276/*
1277 * cap_mmap_addr - check if able to map given addr
1278 * @addr: address attempting to be mapped
1279 *
1280 * If the process is attempting to map memory below dac_mmap_min_addr they need
1281 * CAP_SYS_RAWIO. The other parameters to this function are unused by the
1282 * capability security module. Returns 0 if this mapping should be allowed
1283 * -EPERM if not.
1284 */
1285int cap_mmap_addr(unsigned long addr)
1286{
1287 int ret = 0;
1288
1289 if (addr < dac_mmap_min_addr) {
1290 ret = cap_capable(current_cred(), &init_user_ns, CAP_SYS_RAWIO,
1291 SECURITY_CAP_AUDIT);
1292 /* set PF_SUPERPRIV if it turns out we allow the low mmap */
1293 if (ret == 0)
1294 current->flags |= PF_SUPERPRIV;
1295 }
1296 return ret;
1297}
1298
1299int cap_mmap_file(struct file *file, unsigned long reqprot,
1300 unsigned long prot, unsigned long flags)
1301{
1302 return 0;
1303}
1304
1305#ifdef CONFIG_SECURITY
1306
1307struct security_hook_list capability_hooks[] __lsm_ro_after_init = {
1308 LSM_HOOK_INIT(capable, cap_capable),
1309 LSM_HOOK_INIT(settime, cap_settime),
1310 LSM_HOOK_INIT(ptrace_access_check, cap_ptrace_access_check),
1311 LSM_HOOK_INIT(ptrace_traceme, cap_ptrace_traceme),
1312 LSM_HOOK_INIT(capget, cap_capget),
1313 LSM_HOOK_INIT(capset, cap_capset),
1314 LSM_HOOK_INIT(bprm_set_creds, cap_bprm_set_creds),
1315 LSM_HOOK_INIT(inode_need_killpriv, cap_inode_need_killpriv),
1316 LSM_HOOK_INIT(inode_killpriv, cap_inode_killpriv),
1317 LSM_HOOK_INIT(inode_getsecurity, cap_inode_getsecurity),
1318 LSM_HOOK_INIT(mmap_addr, cap_mmap_addr),
1319 LSM_HOOK_INIT(mmap_file, cap_mmap_file),
1320 LSM_HOOK_INIT(task_fix_setuid, cap_task_fix_setuid),
1321 LSM_HOOK_INIT(task_prctl, cap_task_prctl),
1322 LSM_HOOK_INIT(task_setscheduler, cap_task_setscheduler),
1323 LSM_HOOK_INIT(task_setioprio, cap_task_setioprio),
1324 LSM_HOOK_INIT(task_setnice, cap_task_setnice),
1325 LSM_HOOK_INIT(vm_enough_memory, cap_vm_enough_memory),
1326};
1327
1328void __init capability_add_hooks(void)
1329{
1330 security_add_hooks(capability_hooks, ARRAY_SIZE(capability_hooks),
1331 "capability");
1332}
1333
1334#endif /* CONFIG_SECURITY */