2 * AppArmor security module
4 * This file contains AppArmor LSM hooks.
6 * Copyright (C) 1998-2008 Novell/SUSE
7 * Copyright 2009-2010 Canonical Ltd.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation, version 2 of the
15 #include <linux/lsm_hooks.h>
16 #include <linux/moduleparam.h>
18 #include <linux/mman.h>
19 #include <linux/mount.h>
20 #include <linux/namei.h>
21 #include <linux/ptrace.h>
22 #include <linux/ctype.h>
23 #include <linux/sysctl.h>
24 #include <linux/audit.h>
25 #include <linux/user_namespace.h>
26 #include <linux/kmemleak.h>
29 #include "include/af_unix.h"
30 #include "include/apparmor.h"
31 #include "include/apparmorfs.h"
32 #include "include/audit.h"
33 #include "include/capability.h"
34 #include "include/context.h"
35 #include "include/file.h"
36 #include "include/ipc.h"
37 #include "include/net.h"
38 #include "include/path.h"
39 #include "include/label.h"
40 #include "include/policy.h"
41 #include "include/policy_ns.h"
42 #include "include/procattr.h"
43 #include "include/mount.h"
45 /* Flag indicating whether initialization completed */
46 int apparmor_initialized
;
48 DEFINE_PER_CPU(struct aa_buffers
, aa_buffers
);
56 * free the associated aa_task_ctx and put its labels
58 static void apparmor_cred_free(struct cred
*cred
)
60 aa_free_task_context(cred_ctx(cred
));
64 * prepare new aa_task_ctx for modification by prepare_cred block
66 static int apparmor_cred_prepare(struct cred
*new, const struct cred
*old
,
69 aa_dup_task_context(cred_ctx(new), cred_ctx(old
));
74 * transfer the apparmor data to a blank set of creds
76 static void apparmor_cred_transfer(struct cred
*new, const struct cred
*old
)
78 const struct aa_task_ctx
*old_ctx
= cred_ctx(old
);
79 struct aa_task_ctx
*new_ctx
= cred_ctx(new);
81 aa_dup_task_context(new_ctx
, old_ctx
);
84 static int apparmor_ptrace_access_check(struct task_struct
*child
,
87 struct aa_label
*tracer
, *tracee
;
90 tracer
= begin_current_label_crit_section();
91 tracee
= aa_get_task_label(child
);
92 error
= aa_may_ptrace(tracer
, tracee
,
93 mode
== PTRACE_MODE_READ
? AA_PTRACE_READ
: AA_PTRACE_TRACE
);
95 end_current_label_crit_section(tracer
);
100 static int apparmor_ptrace_traceme(struct task_struct
*parent
)
102 struct aa_label
*tracer
, *tracee
;
105 tracee
= begin_current_label_crit_section();
106 tracer
= aa_get_task_label(parent
);
107 error
= aa_may_ptrace(tracer
, tracee
, AA_PTRACE_TRACE
);
108 aa_put_label(tracer
);
109 end_current_label_crit_section(tracee
);
114 /* Derived from security/commoncap.c:cap_capget */
115 static int apparmor_capget(struct task_struct
*target
, kernel_cap_t
*effective
,
116 kernel_cap_t
*inheritable
, kernel_cap_t
*permitted
)
118 struct aa_label
*label
;
119 const struct cred
*cred
;
122 cred
= __task_cred(target
);
123 label
= aa_get_newest_cred_label(cred
);
126 * cap_capget is stacked ahead of this and will
127 * initialize effective and permitted.
129 if (!unconfined(label
)) {
130 struct aa_profile
*profile
;
133 label_for_each_confined(i
, label
, profile
) {
134 if (COMPLAIN_MODE(profile
))
136 *effective
= cap_intersect(*effective
,
137 profile
->caps
.allow
);
138 *permitted
= cap_intersect(*permitted
,
139 profile
->caps
.allow
);
148 static int apparmor_capable(const struct cred
*cred
, struct user_namespace
*ns
,
151 struct aa_label
*label
;
154 label
= aa_get_newest_cred_label(cred
);
155 if (!unconfined(label
))
156 error
= aa_capable(label
, cap
, audit
);
163 * common_perm - basic common permission check wrapper fn for paths
164 * @op: operation being checked
165 * @path: path to check permission of (NOT NULL)
166 * @mask: requested permissions mask
167 * @cond: conditional info for the permission request (NOT NULL)
169 * Returns: %0 else error code if error or permission denied
171 static int common_perm(const char *op
, const struct path
*path
, u32 mask
,
172 struct path_cond
*cond
)
174 struct aa_label
*label
;
177 label
= __begin_current_label_crit_section();
178 if (!unconfined(label
))
179 error
= aa_path_perm(op
, label
, path
, 0, mask
, cond
);
180 __end_current_label_crit_section(label
);
186 * common_perm_cond - common permission wrapper around inode cond
187 * @op: operation being checked
188 * @path: location to check (NOT NULL)
189 * @mask: requested permissions mask
191 * Returns: %0 else error code if error or permission denied
193 static int common_perm_cond(const char *op
, const struct path
*path
, u32 mask
)
195 struct path_cond cond
= { d_backing_inode(path
->dentry
)->i_uid
,
196 d_backing_inode(path
->dentry
)->i_mode
199 if (!path_mediated_fs(path
->dentry
))
202 return common_perm(op
, path
, mask
, &cond
);
206 * common_perm_dir_dentry - common permission wrapper when path is dir, dentry
207 * @op: operation being checked
208 * @dir: directory of the dentry (NOT NULL)
209 * @dentry: dentry to check (NOT NULL)
210 * @mask: requested permissions mask
211 * @cond: conditional info for the permission request (NOT NULL)
213 * Returns: %0 else error code if error or permission denied
215 static int common_perm_dir_dentry(const char *op
, const struct path
*dir
,
216 struct dentry
*dentry
, u32 mask
,
217 struct path_cond
*cond
)
219 struct path path
= { .mnt
= dir
->mnt
, .dentry
= dentry
};
221 return common_perm(op
, &path
, mask
, cond
);
225 * common_perm_rm - common permission wrapper for operations doing rm
226 * @op: operation being checked
227 * @dir: directory that the dentry is in (NOT NULL)
228 * @dentry: dentry being rm'd (NOT NULL)
229 * @mask: requested permission mask
231 * Returns: %0 else error code if error or permission denied
233 static int common_perm_rm(const char *op
, const struct path
*dir
,
234 struct dentry
*dentry
, u32 mask
)
236 struct inode
*inode
= d_backing_inode(dentry
);
237 struct path_cond cond
= { };
239 if (!inode
|| !path_mediated_fs(dentry
))
242 cond
.uid
= inode
->i_uid
;
243 cond
.mode
= inode
->i_mode
;
245 return common_perm_dir_dentry(op
, dir
, dentry
, mask
, &cond
);
249 * common_perm_create - common permission wrapper for operations doing create
250 * @op: operation being checked
251 * @dir: directory that dentry will be created in (NOT NULL)
252 * @dentry: dentry to create (NOT NULL)
253 * @mask: request permission mask
254 * @mode: created file mode
256 * Returns: %0 else error code if error or permission denied
258 static int common_perm_create(const char *op
, const struct path
*dir
,
259 struct dentry
*dentry
, u32 mask
, umode_t mode
)
261 struct path_cond cond
= { current_fsuid(), mode
};
263 if (!path_mediated_fs(dir
->dentry
))
266 return common_perm_dir_dentry(op
, dir
, dentry
, mask
, &cond
);
269 static int apparmor_path_unlink(const struct path
*dir
, struct dentry
*dentry
)
271 return common_perm_rm(OP_UNLINK
, dir
, dentry
, AA_MAY_DELETE
);
274 static int apparmor_path_mkdir(const struct path
*dir
, struct dentry
*dentry
,
277 return common_perm_create(OP_MKDIR
, dir
, dentry
, AA_MAY_CREATE
,
281 static int apparmor_path_rmdir(const struct path
*dir
, struct dentry
*dentry
)
283 return common_perm_rm(OP_RMDIR
, dir
, dentry
, AA_MAY_DELETE
);
286 static int apparmor_path_mknod(const struct path
*dir
, struct dentry
*dentry
,
287 umode_t mode
, unsigned int dev
)
289 return common_perm_create(OP_MKNOD
, dir
, dentry
, AA_MAY_CREATE
, mode
);
292 static int apparmor_path_truncate(const struct path
*path
)
294 return common_perm_cond(OP_TRUNC
, path
, MAY_WRITE
| AA_MAY_SETATTR
);
297 static int apparmor_path_symlink(const struct path
*dir
, struct dentry
*dentry
,
298 const char *old_name
)
300 return common_perm_create(OP_SYMLINK
, dir
, dentry
, AA_MAY_CREATE
,
304 static int apparmor_path_link(struct dentry
*old_dentry
, const struct path
*new_dir
,
305 struct dentry
*new_dentry
)
307 struct aa_label
*label
;
310 if (!path_mediated_fs(old_dentry
))
313 label
= begin_current_label_crit_section();
314 if (!unconfined(label
))
315 error
= aa_path_link(label
, old_dentry
, new_dir
, new_dentry
);
316 end_current_label_crit_section(label
);
321 static int apparmor_path_rename(const struct path
*old_dir
, struct dentry
*old_dentry
,
322 const struct path
*new_dir
, struct dentry
*new_dentry
)
324 struct aa_label
*label
;
327 if (!path_mediated_fs(old_dentry
))
330 label
= begin_current_label_crit_section();
331 if (!unconfined(label
)) {
332 struct path old_path
= { .mnt
= old_dir
->mnt
,
333 .dentry
= old_dentry
};
334 struct path new_path
= { .mnt
= new_dir
->mnt
,
335 .dentry
= new_dentry
};
336 struct path_cond cond
= { d_backing_inode(old_dentry
)->i_uid
,
337 d_backing_inode(old_dentry
)->i_mode
340 error
= aa_path_perm(OP_RENAME_SRC
, label
, &old_path
, 0,
341 MAY_READ
| AA_MAY_GETATTR
| MAY_WRITE
|
342 AA_MAY_SETATTR
| AA_MAY_DELETE
,
345 error
= aa_path_perm(OP_RENAME_DEST
, label
, &new_path
,
346 0, MAY_WRITE
| AA_MAY_SETATTR
|
347 AA_MAY_CREATE
, &cond
);
350 end_current_label_crit_section(label
);
355 static int apparmor_path_chmod(const struct path
*path
, umode_t mode
)
357 return common_perm_cond(OP_CHMOD
, path
, AA_MAY_CHMOD
);
360 static int apparmor_path_chown(const struct path
*path
, kuid_t uid
, kgid_t gid
)
362 return common_perm_cond(OP_CHOWN
, path
, AA_MAY_CHOWN
);
365 static int apparmor_inode_getattr(const struct path
*path
)
367 return common_perm_cond(OP_GETATTR
, path
, AA_MAY_GETATTR
);
370 static int apparmor_file_open(struct file
*file
, const struct cred
*cred
)
372 struct aa_file_ctx
*fctx
= file_ctx(file
);
373 struct aa_label
*label
;
376 if (!path_mediated_fs(file
->f_path
.dentry
))
379 /* If in exec, permission is handled by bprm hooks.
380 * Cache permissions granted by the previous exec check, with
381 * implicit read and executable mmap which are required to
382 * actually execute the image.
384 if (current
->in_execve
) {
385 fctx
->allow
= MAY_EXEC
| MAY_READ
| AA_EXEC_MMAP
;
389 label
= aa_get_newest_cred_label(cred
);
390 if (!unconfined(label
)) {
391 struct inode
*inode
= file_inode(file
);
392 struct path_cond cond
= { inode
->i_uid
, inode
->i_mode
};
394 error
= aa_path_perm(OP_OPEN
, label
, &file
->f_path
, 0,
395 aa_map_file_to_perms(file
), &cond
);
396 /* todo cache full allowed permissions set and state */
397 fctx
->allow
= aa_map_file_to_perms(file
);
404 static int apparmor_file_alloc_security(struct file
*file
)
406 struct aa_file_ctx
*ctx
= file_ctx(file
);
407 struct aa_label
*label
= begin_current_label_crit_section();
409 spin_lock_init(&ctx
->lock
);
410 rcu_assign_pointer(ctx
->label
, aa_get_label(label
));
411 end_current_label_crit_section(label
);
415 static void apparmor_file_free_security(struct file
*file
)
417 struct aa_file_ctx
*ctx
= file_ctx(file
);
420 aa_put_label(rcu_access_pointer(ctx
->label
));
423 static int common_file_perm(const char *op
, struct file
*file
, u32 mask
)
425 struct aa_label
*label
;
428 /* don't reaudit files closed during inheritance */
429 if (file
->f_path
.dentry
== aa_null
.dentry
)
432 label
= __begin_current_label_crit_section();
433 error
= aa_file_perm(op
, label
, file
, mask
);
434 __end_current_label_crit_section(label
);
439 static int apparmor_file_receive(struct file
*file
)
441 return common_file_perm(OP_FRECEIVE
, file
, aa_map_file_to_perms(file
));
444 static int apparmor_file_permission(struct file
*file
, int mask
)
446 return common_file_perm(OP_FPERM
, file
, mask
);
449 static int apparmor_file_lock(struct file
*file
, unsigned int cmd
)
451 u32 mask
= AA_MAY_LOCK
;
456 return common_file_perm(OP_FLOCK
, file
, mask
);
459 static int common_mmap(const char *op
, struct file
*file
, unsigned long prot
,
464 if (!file
|| !file_ctx(file
))
467 if (prot
& PROT_READ
)
470 * Private mappings don't require write perms since they don't
471 * write back to the files
473 if ((prot
& PROT_WRITE
) && !(flags
& MAP_PRIVATE
))
475 if (prot
& PROT_EXEC
)
476 mask
|= AA_EXEC_MMAP
;
478 return common_file_perm(op
, file
, mask
);
481 static int apparmor_mmap_file(struct file
*file
, unsigned long reqprot
,
482 unsigned long prot
, unsigned long flags
)
484 return common_mmap(OP_FMMAP
, file
, prot
, flags
);
487 static int apparmor_file_mprotect(struct vm_area_struct
*vma
,
488 unsigned long reqprot
, unsigned long prot
)
490 return common_mmap(OP_FMPROT
, vma
->vm_file
, prot
,
491 !(vma
->vm_flags
& VM_SHARED
) ? MAP_PRIVATE
: 0);
494 static int apparmor_sb_mount(const char *dev_name
, const struct path
*path
,
495 const char *type
, unsigned long flags
, void *data
)
497 struct aa_label
*label
;
501 if ((flags
& MS_MGC_MSK
) == MS_MGC_VAL
)
502 flags
&= ~MS_MGC_MSK
;
504 flags
&= ~AA_MS_IGNORE_MASK
;
506 label
= __begin_current_label_crit_section();
507 if (!unconfined(label
)) {
508 if (flags
& MS_REMOUNT
)
509 error
= aa_remount(label
, path
, flags
, data
);
510 else if (flags
& MS_BIND
)
511 error
= aa_bind_mount(label
, path
, dev_name
, flags
);
512 else if (flags
& (MS_SHARED
| MS_PRIVATE
| MS_SLAVE
|
514 error
= aa_mount_change_type(label
, path
, flags
);
515 else if (flags
& MS_MOVE
)
516 error
= aa_move_mount(label
, path
, dev_name
);
518 error
= aa_new_mount(label
, dev_name
, path
, type
,
521 __end_current_label_crit_section(label
);
526 static int apparmor_sb_umount(struct vfsmount
*mnt
, int flags
)
528 struct aa_label
*label
;
531 label
= __begin_current_label_crit_section();
532 if (!unconfined(label
))
533 error
= aa_umount(label
, mnt
, flags
);
534 __end_current_label_crit_section(label
);
539 static int apparmor_sb_pivotroot(const struct path
*old_path
,
540 const struct path
*new_path
)
542 struct aa_label
*label
;
545 label
= aa_get_current_label();
546 if (!unconfined(label
))
547 error
= aa_pivotroot(label
, old_path
, new_path
);
553 static int apparmor_getprocattr(struct task_struct
*task
, char *name
,
558 const struct cred
*cred
= get_task_cred(task
);
559 struct aa_task_ctx
*ctx
= cred_ctx(cred
);
560 struct aa_label
*label
= NULL
;
564 if (strcmp(name
, "current") == 0)
565 label
= aa_get_newest_label(ctx
->label
);
566 else if (strcmp(name
, "context") == 0 && ctx
->label
)
567 label
= aa_get_newest_label(ctx
->label
);
568 else if (strcmp(name
, "prev") == 0 && ctx
->previous
)
569 label
= aa_get_newest_label(ctx
->previous
);
570 else if (strcmp(name
, "exec") == 0 && ctx
->onexec
)
571 label
= aa_get_newest_label(ctx
->onexec
);
578 error
= aa_getprocattr(label
, &vp
);
582 if (strcmp(name
, "context") == 0) {
583 *value
= kasprintf(GFP_KERNEL
, "apparmor='%s'", vp
);
584 if (*value
== NULL
) {
588 np
= strchr(*value
, '\n');
593 error
= strlen(*value
);
605 static int apparmor_setprocattr(const char *name
, void *value
,
608 char *command
, *largs
= NULL
, *args
= value
;
611 DEFINE_AUDIT_DATA(sa
, LSM_AUDIT_DATA_NONE
, OP_SETPROCATTR
);
616 /* AppArmor requires that the buffer must be null terminated atm */
617 if (args
[size
- 1] != '\0') {
619 largs
= args
= kmalloc(size
+ 1, GFP_KERNEL
);
622 memcpy(args
, value
, size
);
628 command
= strsep(&args
, " ");
631 args
= skip_spaces(args
);
635 arg_size
= size
- (args
- (largs
? largs
: (char *) value
));
636 if (strcmp(name
, "current") == 0 || strcmp(name
, "context") == 0) {
637 if (strcmp(command
, "changehat") == 0) {
638 error
= aa_setprocattr_changehat(args
, arg_size
,
640 } else if (strcmp(command
, "permhat") == 0) {
641 error
= aa_setprocattr_changehat(args
, arg_size
,
643 } else if (strcmp(command
, "changeprofile") == 0) {
644 error
= aa_change_profile(args
, AA_CHANGE_NOFLAGS
);
645 } else if (strcmp(command
, "permprofile") == 0) {
646 error
= aa_change_profile(args
, AA_CHANGE_TEST
);
647 } else if (strcmp(command
, "stack") == 0) {
648 error
= aa_change_profile(args
, AA_CHANGE_STACK
);
651 } else if (strcmp(name
, "exec") == 0) {
652 if (strcmp(command
, "exec") == 0)
653 error
= aa_change_profile(args
, AA_CHANGE_ONEXEC
);
654 else if (strcmp(command
, "stack") == 0)
655 error
= aa_change_profile(args
, (AA_CHANGE_ONEXEC
|
661 * only support the "current", "context" and "exec"
673 aad(&sa
)->label
= begin_current_label_crit_section();
674 aad(&sa
)->info
= name
;
675 aad(&sa
)->error
= error
= -EINVAL
;
676 aa_audit_msg(AUDIT_APPARMOR_DENIED
, &sa
, NULL
);
677 end_current_label_crit_section(aad(&sa
)->label
);
682 * apparmor_bprm_committing_creds - do task cleanup on committing new creds
683 * @bprm: binprm for the exec (NOT NULL)
685 static void apparmor_bprm_committing_creds(struct linux_binprm
*bprm
)
687 struct aa_label
*label
= aa_current_raw_label();
688 struct aa_task_ctx
*new_ctx
= cred_ctx(bprm
->cred
);
690 /* bail out if unconfined or not changing profile */
691 if ((new_ctx
->label
->proxy
== label
->proxy
) ||
692 (unconfined(new_ctx
->label
)))
695 aa_inherit_files(bprm
->cred
, current
->files
);
697 current
->pdeath_signal
= 0;
699 /* reset soft limits and set hard limits for the new label */
700 __aa_transition_rlimits(label
, new_ctx
->label
);
704 * apparmor_bprm_committed_cred - do cleanup after new creds committed
705 * @bprm: binprm for the exec (NOT NULL)
707 static void apparmor_bprm_committed_creds(struct linux_binprm
*bprm
)
709 /* TODO: cleanup signals - ipc mediation */
713 static int apparmor_task_setrlimit(struct task_struct
*task
,
714 unsigned int resource
, struct rlimit
*new_rlim
)
716 struct aa_label
*label
= __begin_current_label_crit_section();
719 if (!unconfined(label
))
720 error
= aa_task_setrlimit(label
, task
, resource
, new_rlim
);
721 __end_current_label_crit_section(label
);
726 static int apparmor_task_kill(struct task_struct
*target
, struct siginfo
*info
,
729 struct aa_label
*cl
, *tl
;
733 /* TODO: after secid to label mapping is done.
734 * Dealing with USB IO specific behavior
737 cl
= __begin_current_label_crit_section();
738 tl
= aa_get_task_label(target
);
739 error
= aa_may_signal(cl
, tl
, sig
);
741 __end_current_label_crit_section(cl
);
747 * apparmor_sk_alloc_security - allocate and attach the sk_security field
749 static int apparmor_sk_alloc_security(struct sock
*sk
, int family
, gfp_t flags
)
751 /* allocated and cleared by LSM */
757 * apparmor_sk_free_security - free the sk_security field
759 static void apparmor_sk_free_security(struct sock
*sk
)
761 struct aa_sk_ctx
*ctx
= SK_CTX(sk
);
763 aa_put_label(ctx
->label
);
765 aa_put_label(ctx
->peer
);
767 path_put(&ctx
->path
);
768 ctx
->path
.dentry
= NULL
;
769 ctx
->path
.mnt
= NULL
;
773 * apparmor_clone_security - clone the sk_security field
775 static void apparmor_sk_clone_security(const struct sock
*sk
,
778 struct aa_sk_ctx
*ctx
= SK_CTX(sk
);
779 struct aa_sk_ctx
*new = SK_CTX(newsk
);
781 new->label
= aa_get_label(ctx
->label
);
782 new->peer
= aa_get_label(ctx
->peer
);
783 new->path
= ctx
->path
;
784 path_get(&new->path
);
787 static struct path
*UNIX_FS_CONN_PATH(struct sock
*sk
, struct sock
*newsk
)
789 if (sk
->sk_family
== PF_UNIX
&& UNIX_FS(sk
))
790 return &unix_sk(sk
)->path
;
791 else if (newsk
->sk_family
== PF_UNIX
&& UNIX_FS(newsk
))
792 return &unix_sk(newsk
)->path
;
797 * apparmor_unix_stream_connect - check perms before making unix domain conn
799 * peer is locked when this hook is called
801 static int apparmor_unix_stream_connect(struct sock
*sk
, struct sock
*peer_sk
,
804 struct aa_sk_ctx
*sk_ctx
= SK_CTX(sk
);
805 struct aa_sk_ctx
*peer_ctx
= SK_CTX(peer_sk
);
806 struct aa_sk_ctx
*new_ctx
= SK_CTX(newsk
);
807 struct aa_label
*label
;
811 label
= __begin_current_label_crit_section();
812 error
= aa_unix_peer_perm(label
, OP_CONNECT
,
813 (AA_MAY_CONNECT
| AA_MAY_SEND
| AA_MAY_RECEIVE
),
815 if (!UNIX_FS(peer_sk
)) {
817 aa_unix_peer_perm(peer_ctx
->label
, OP_CONNECT
,
818 (AA_MAY_ACCEPT
| AA_MAY_SEND
| AA_MAY_RECEIVE
),
819 peer_sk
, sk
, label
));
821 __end_current_label_crit_section(label
);
826 /* label newsk if it wasn't labeled in post_create. Normally this
827 * would be done in sock_graft, but because we are directly looking
828 * at the peer_sk to obtain peer_labeling for unix socks this
832 new_ctx
->label
= aa_get_label(peer_ctx
->label
);
834 /* Cross reference the peer labels for SO_PEERSEC */
836 aa_put_label(new_ctx
->peer
);
839 aa_put_label(sk_ctx
->peer
);
841 new_ctx
->peer
= aa_get_label(sk_ctx
->label
);
842 sk_ctx
->peer
= aa_get_label(peer_ctx
->label
);
844 path
= UNIX_FS_CONN_PATH(sk
, peer_sk
);
846 new_ctx
->path
= *path
;
847 sk_ctx
->path
= *path
;
855 * apparmor_unix_may_send - check perms before conn or sending unix dgrams
857 * other is locked when this hook is called
859 * dgram connect calls may_send, peer setup but path not copied?????
861 static int apparmor_unix_may_send(struct socket
*sock
, struct socket
*peer
)
863 struct aa_sk_ctx
*peer_ctx
= SK_CTX(peer
->sk
);
864 struct aa_label
*label
;
867 label
= __begin_current_label_crit_section();
868 error
= xcheck(aa_unix_peer_perm(label
, OP_SENDMSG
, AA_MAY_SEND
,
869 sock
->sk
, peer
->sk
, NULL
),
870 aa_unix_peer_perm(peer_ctx
->label
, OP_SENDMSG
,
872 peer
->sk
, sock
->sk
, label
));
873 __end_current_label_crit_section(label
);
879 * apparmor_socket_create - check perms before creating a new socket
881 static int apparmor_socket_create(int family
, int type
, int protocol
, int kern
)
883 struct aa_label
*label
;
886 label
= begin_current_label_crit_section();
887 if (!(kern
|| unconfined(label
)))
888 error
= aa_sock_create_perm(label
, family
, type
, protocol
);
889 end_current_label_crit_section(label
);
895 * apparmor_socket_post_create - setup the per-socket security struct
898 * - kernel sockets currently labeled unconfined but we may want to
899 * move to a special kernel label
900 * - socket may not have sk here if created with sock_create_lite or
901 * sock_alloc. These should be accept cases which will be handled in
904 static int apparmor_socket_post_create(struct socket
*sock
, int family
,
905 int type
, int protocol
, int kern
)
907 struct aa_label
*label
;
910 struct aa_ns
*ns
= aa_get_current_ns();
912 label
= aa_get_label(ns_unconfined(ns
));
915 label
= aa_get_current_label();
918 struct aa_sk_ctx
*ctx
= SK_CTX(sock
->sk
);
920 aa_put_label(ctx
->label
);
921 ctx
->label
= aa_get_label(label
);
929 * apparmor_socket_bind - check perms before bind addr to socket
931 static int apparmor_socket_bind(struct socket
*sock
,
932 struct sockaddr
*address
, int addrlen
)
934 return aa_sock_bind_perm(sock
, address
, addrlen
);
938 * apparmor_socket_connect - check perms before connecting @sock to @address
940 static int apparmor_socket_connect(struct socket
*sock
,
941 struct sockaddr
*address
, int addrlen
)
943 return aa_sock_connect_perm(sock
, address
, addrlen
);
947 * apparmor_socket_list - check perms before allowing listen
949 static int apparmor_socket_listen(struct socket
*sock
, int backlog
)
951 return aa_sock_listen_perm(sock
, backlog
);
955 * apparmor_socket_accept - check perms before accepting a new connection.
957 * Note: while @newsock is created and has some information, the accept
960 static int apparmor_socket_accept(struct socket
*sock
, struct socket
*newsock
)
962 return aa_sock_accept_perm(sock
, newsock
);
966 * apparmor_socket_sendmsg - check perms before sending msg to another socket
968 static int apparmor_socket_sendmsg(struct socket
*sock
,
969 struct msghdr
*msg
, int size
)
971 return aa_sock_msg_perm(OP_SENDMSG
, AA_MAY_SEND
, sock
, msg
, size
);
975 * apparmor_socket_recvmsg - check perms before receiving a message
977 static int apparmor_socket_recvmsg(struct socket
*sock
,
978 struct msghdr
*msg
, int size
, int flags
)
980 return aa_sock_msg_perm(OP_RECVMSG
, AA_MAY_RECEIVE
, sock
, msg
, size
);
984 * apparmor_socket_getsockname - check perms before getting the local address
986 static int apparmor_socket_getsockname(struct socket
*sock
)
988 return aa_sock_perm(OP_GETSOCKNAME
, AA_MAY_GETATTR
, sock
);
992 * apparmor_socket_getpeername - check perms before getting remote address
994 static int apparmor_socket_getpeername(struct socket
*sock
)
996 return aa_sock_perm(OP_GETPEERNAME
, AA_MAY_GETATTR
, sock
);
1000 * apparmor_getsockopt - check perms before getting socket options
1002 static int apparmor_socket_getsockopt(struct socket
*sock
, int level
,
1005 return aa_sock_opt_perm(OP_GETSOCKOPT
, AA_MAY_GETOPT
, sock
,
1010 * apparmor_setsockopt - check perms before setting socket options
1012 static int apparmor_socket_setsockopt(struct socket
*sock
, int level
,
1015 return aa_sock_opt_perm(OP_SETSOCKOPT
, AA_MAY_SETOPT
, sock
,
1020 * apparmor_socket_shutdown - check perms before shutting down @sock conn
1022 static int apparmor_socket_shutdown(struct socket
*sock
, int how
)
1024 return aa_sock_perm(OP_SHUTDOWN
, AA_MAY_SHUTDOWN
, sock
);
1028 * apparmor_socket_sock_recv_skb - check perms before associating skb to sk
1030 * Note: can not sleep may be called with locks held
1032 * dont want protocol specific in __skb_recv_datagram()
1033 * to deny an incoming connection socket_sock_rcv_skb()
1035 static int apparmor_socket_sock_rcv_skb(struct sock
*sk
, struct sk_buff
*skb
)
1041 static struct aa_label
*sk_peer_label(struct sock
*sk
)
1043 struct sock
*peer_sk
;
1044 struct aa_sk_ctx
*ctx
= SK_CTX(sk
);
1049 if (sk
->sk_family
!= PF_UNIX
)
1050 return ERR_PTR(-ENOPROTOOPT
);
1052 /* check for sockpair peering which does not go through
1053 * security_unix_stream_connect
1055 peer_sk
= unix_peer(sk
);
1057 ctx
= SK_CTX(peer_sk
);
1062 return ERR_PTR(-ENOPROTOOPT
);
1066 * apparmor_socket_getpeersec_stream - get security context of peer
1068 * Note: for tcp only valid if using ipsec or cipso on lan
1070 static int apparmor_socket_getpeersec_stream(struct socket
*sock
,
1071 char __user
*optval
,
1076 int slen
, error
= 0;
1077 struct aa_label
*label
;
1078 struct aa_label
*peer
;
1080 label
= begin_current_label_crit_section();
1081 peer
= sk_peer_label(sock
->sk
);
1083 error
= PTR_ERR(peer
);
1086 slen
= aa_label_asxprint(&name
, labels_ns(label
), peer
,
1087 FLAG_SHOW_MODE
| FLAG_VIEW_SUBNS
|
1088 FLAG_HIDDEN_UNCONFINED
, GFP_KERNEL
);
1089 /* don't include terminating \0 in slen, it breaks some apps */
1095 } else if (copy_to_user(optval
, name
, slen
)) {
1099 if (put_user(slen
, optlen
))
1107 end_current_label_crit_section(label
);
1113 * apparmor_socket_getpeersec_dgram - get security label of packet
1114 * @sock: the peer socket
1116 * @secid: pointer to where to put the secid of the packet
1118 * Sets the netlabel socket state on sk from parent
1120 static int apparmor_socket_getpeersec_dgram(struct socket
*sock
,
1121 struct sk_buff
*skb
, u32
*secid
)
1124 /* TODO: requires secid support */
1125 return -ENOPROTOOPT
;
1129 * apparmor_sock_graft - Initialize newly created socket
1131 * @parent: parent socket
1133 * Note: could set off of SOCK_CTX(parent) but need to track inode and we can
1134 * just set sk security information off of current creating process label
1135 * Labeling of sk for accept case - probably should be sock based
1136 * instead of task, because of the case where an implicitly labeled
1137 * socket is shared by different tasks.
1139 static void apparmor_sock_graft(struct sock
*sk
, struct socket
*parent
)
1141 struct aa_sk_ctx
*ctx
= SK_CTX(sk
);
1144 ctx
->label
= aa_get_current_label();
1147 struct lsm_blob_sizes apparmor_blob_sizes
= {
1148 .lbs_cred
= sizeof(struct aa_task_ctx
),
1149 .lbs_file
= sizeof(struct aa_file_ctx
),
1150 .lbs_sock
= sizeof(struct aa_sk_ctx
),
1153 static struct security_hook_list apparmor_hooks
[] __lsm_ro_after_init
= {
1154 LSM_HOOK_INIT(ptrace_access_check
, apparmor_ptrace_access_check
),
1155 LSM_HOOK_INIT(ptrace_traceme
, apparmor_ptrace_traceme
),
1156 LSM_HOOK_INIT(capget
, apparmor_capget
),
1157 LSM_HOOK_INIT(capable
, apparmor_capable
),
1159 LSM_HOOK_INIT(sb_mount
, apparmor_sb_mount
),
1160 LSM_HOOK_INIT(sb_umount
, apparmor_sb_umount
),
1161 LSM_HOOK_INIT(sb_pivotroot
, apparmor_sb_pivotroot
),
1163 LSM_HOOK_INIT(path_link
, apparmor_path_link
),
1164 LSM_HOOK_INIT(path_unlink
, apparmor_path_unlink
),
1165 LSM_HOOK_INIT(path_symlink
, apparmor_path_symlink
),
1166 LSM_HOOK_INIT(path_mkdir
, apparmor_path_mkdir
),
1167 LSM_HOOK_INIT(path_rmdir
, apparmor_path_rmdir
),
1168 LSM_HOOK_INIT(path_mknod
, apparmor_path_mknod
),
1169 LSM_HOOK_INIT(path_rename
, apparmor_path_rename
),
1170 LSM_HOOK_INIT(path_chmod
, apparmor_path_chmod
),
1171 LSM_HOOK_INIT(path_chown
, apparmor_path_chown
),
1172 LSM_HOOK_INIT(path_truncate
, apparmor_path_truncate
),
1173 LSM_HOOK_INIT(inode_getattr
, apparmor_inode_getattr
),
1175 LSM_HOOK_INIT(file_open
, apparmor_file_open
),
1176 LSM_HOOK_INIT(file_receive
, apparmor_file_receive
),
1177 LSM_HOOK_INIT(file_permission
, apparmor_file_permission
),
1178 LSM_HOOK_INIT(file_alloc_security
, apparmor_file_alloc_security
),
1179 LSM_HOOK_INIT(file_free_security
, apparmor_file_free_security
),
1180 LSM_HOOK_INIT(mmap_file
, apparmor_mmap_file
),
1181 LSM_HOOK_INIT(file_mprotect
, apparmor_file_mprotect
),
1182 LSM_HOOK_INIT(file_lock
, apparmor_file_lock
),
1184 LSM_HOOK_INIT(getprocattr
, apparmor_getprocattr
),
1185 LSM_HOOK_INIT(setprocattr
, apparmor_setprocattr
),
1187 LSM_HOOK_INIT(sk_alloc_security
, apparmor_sk_alloc_security
),
1188 LSM_HOOK_INIT(sk_free_security
, apparmor_sk_free_security
),
1189 LSM_HOOK_INIT(sk_clone_security
, apparmor_sk_clone_security
),
1191 LSM_HOOK_INIT(unix_stream_connect
, apparmor_unix_stream_connect
),
1192 LSM_HOOK_INIT(unix_may_send
, apparmor_unix_may_send
),
1194 LSM_HOOK_INIT(socket_create
, apparmor_socket_create
),
1195 LSM_HOOK_INIT(socket_post_create
, apparmor_socket_post_create
),
1196 LSM_HOOK_INIT(socket_bind
, apparmor_socket_bind
),
1197 LSM_HOOK_INIT(socket_connect
, apparmor_socket_connect
),
1198 LSM_HOOK_INIT(socket_listen
, apparmor_socket_listen
),
1199 LSM_HOOK_INIT(socket_accept
, apparmor_socket_accept
),
1200 LSM_HOOK_INIT(socket_sendmsg
, apparmor_socket_sendmsg
),
1201 LSM_HOOK_INIT(socket_recvmsg
, apparmor_socket_recvmsg
),
1202 LSM_HOOK_INIT(socket_getsockname
, apparmor_socket_getsockname
),
1203 LSM_HOOK_INIT(socket_getpeername
, apparmor_socket_getpeername
),
1204 LSM_HOOK_INIT(socket_getsockopt
, apparmor_socket_getsockopt
),
1205 LSM_HOOK_INIT(socket_setsockopt
, apparmor_socket_setsockopt
),
1206 LSM_HOOK_INIT(socket_shutdown
, apparmor_socket_shutdown
),
1207 LSM_HOOK_INIT(socket_sock_rcv_skb
, apparmor_socket_sock_rcv_skb
),
1208 LSM_HOOK_INIT(socket_getpeersec_stream
,
1209 apparmor_socket_getpeersec_stream
),
1210 LSM_HOOK_INIT(socket_getpeersec_dgram
,
1211 apparmor_socket_getpeersec_dgram
),
1212 LSM_HOOK_INIT(sock_graft
, apparmor_sock_graft
),
1214 LSM_HOOK_INIT(cred_free
, apparmor_cred_free
),
1215 LSM_HOOK_INIT(cred_prepare
, apparmor_cred_prepare
),
1216 LSM_HOOK_INIT(cred_transfer
, apparmor_cred_transfer
),
1218 LSM_HOOK_INIT(bprm_set_creds
, apparmor_bprm_set_creds
),
1219 LSM_HOOK_INIT(bprm_committing_creds
, apparmor_bprm_committing_creds
),
1220 LSM_HOOK_INIT(bprm_committed_creds
, apparmor_bprm_committed_creds
),
1221 LSM_HOOK_INIT(bprm_secureexec
, apparmor_bprm_secureexec
),
1223 LSM_HOOK_INIT(task_setrlimit
, apparmor_task_setrlimit
),
1224 LSM_HOOK_INIT(task_kill
, apparmor_task_kill
),
1228 * AppArmor sysfs module parameters
1231 static int param_set_aabool(const char *val
, const struct kernel_param
*kp
);
1232 static int param_get_aabool(char *buffer
, const struct kernel_param
*kp
);
1233 #define param_check_aabool param_check_bool
1234 static const struct kernel_param_ops param_ops_aabool
= {
1235 .flags
= KERNEL_PARAM_OPS_FL_NOARG
,
1236 .set
= param_set_aabool
,
1237 .get
= param_get_aabool
1240 static int param_set_aauint(const char *val
, const struct kernel_param
*kp
);
1241 static int param_get_aauint(char *buffer
, const struct kernel_param
*kp
);
1242 #define param_check_aauint param_check_uint
1243 static const struct kernel_param_ops param_ops_aauint
= {
1244 .set
= param_set_aauint
,
1245 .get
= param_get_aauint
1248 static int param_set_aalockpolicy(const char *val
, const struct kernel_param
*kp
);
1249 static int param_get_aalockpolicy(char *buffer
, const struct kernel_param
*kp
);
1250 #define param_check_aalockpolicy param_check_bool
1251 static const struct kernel_param_ops param_ops_aalockpolicy
= {
1252 .flags
= KERNEL_PARAM_OPS_FL_NOARG
,
1253 .set
= param_set_aalockpolicy
,
1254 .get
= param_get_aalockpolicy
1257 static int param_set_audit(const char *val
, struct kernel_param
*kp
);
1258 static int param_get_audit(char *buffer
, struct kernel_param
*kp
);
1260 static int param_set_mode(const char *val
, struct kernel_param
*kp
);
1261 static int param_get_mode(char *buffer
, struct kernel_param
*kp
);
1263 /* Flag values, also controllable via /sys/module/apparmor/parameters
1264 * We define special types as we want to do additional mediation.
1267 /* AppArmor global enforcement switch - complain, enforce, kill */
1268 enum profile_mode aa_g_profile_mode
= APPARMOR_ENFORCE
;
1269 module_param_call(mode
, param_set_mode
, param_get_mode
,
1270 &aa_g_profile_mode
, S_IRUSR
| S_IWUSR
);
1272 /* whether policy verification hashing is enabled */
1273 bool aa_g_hash_policy
= IS_ENABLED(CONFIG_SECURITY_APPARMOR_HASH_DEFAULT
);
1274 #ifdef CONFIG_SECURITY_APPARMOR_HASH
1275 module_param_named(hash_policy
, aa_g_hash_policy
, aabool
, S_IRUSR
| S_IWUSR
);
1279 bool aa_g_debug
= IS_ENABLED(CONFIG_SECURITY_APPARMOR_DEBUG_MESSAGES
);
1280 module_param_named(debug
, aa_g_debug
, aabool
, S_IRUSR
| S_IWUSR
);
1283 enum audit_mode aa_g_audit
;
1284 module_param_call(audit
, param_set_audit
, param_get_audit
,
1285 &aa_g_audit
, S_IRUSR
| S_IWUSR
);
1287 /* Determines if audit header is included in audited messages. This
1288 * provides more context if the audit daemon is not running
1290 bool aa_g_audit_header
= 1;
1291 module_param_named(audit_header
, aa_g_audit_header
, aabool
,
1294 /* lock out loading/removal of policy
1295 * TODO: add in at boot loading of policy, which is the only way to
1296 * load policy, if lock_policy is set
1298 bool aa_g_lock_policy
;
1299 module_param_named(lock_policy
, aa_g_lock_policy
, aalockpolicy
,
1302 /* Syscall logging mode */
1303 bool aa_g_logsyscall
;
1304 module_param_named(logsyscall
, aa_g_logsyscall
, aabool
, S_IRUSR
| S_IWUSR
);
1306 /* Maximum pathname length before accesses will start getting rejected */
1307 unsigned int aa_g_path_max
= 2 * PATH_MAX
;
1308 module_param_named(path_max
, aa_g_path_max
, aauint
, S_IRUSR
);
1310 /* Determines how paranoid loading of policy is and how much verification
1311 * on the loaded policy is done.
1312 * DEPRECATED: read only as strict checking of load is always done now
1313 * that none root users (user namespaces) can load policy.
1315 bool aa_g_paranoid_load
= 1;
1316 module_param_named(paranoid_load
, aa_g_paranoid_load
, aabool
, S_IRUGO
);
1318 /* Boot time disable flag */
1319 static bool apparmor_enabled
= CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE
;
1320 module_param_named(enabled
, apparmor_enabled
, bool, S_IRUGO
);
1322 static int __init
apparmor_enabled_setup(char *str
)
1324 unsigned long enabled
;
1325 int error
= kstrtoul(str
, 0, &enabled
);
1327 apparmor_enabled
= enabled
? 1 : 0;
1331 __setup("apparmor=", apparmor_enabled_setup
);
1333 /* set global flag turning off the ability to load policy */
1334 static int param_set_aalockpolicy(const char *val
, const struct kernel_param
*kp
)
1336 if (!apparmor_enabled
)
1338 if (apparmor_initialized
&& !policy_admin_capable(NULL
))
1340 return param_set_bool(val
, kp
);
1343 static int param_get_aalockpolicy(char *buffer
, const struct kernel_param
*kp
)
1345 if (!apparmor_enabled
)
1347 if (apparmor_initialized
&& !policy_view_capable(NULL
))
1349 return param_get_bool(buffer
, kp
);
1352 static int param_set_aabool(const char *val
, const struct kernel_param
*kp
)
1354 if (!apparmor_enabled
)
1356 if (apparmor_initialized
&& !policy_admin_capable(NULL
))
1358 return param_set_bool(val
, kp
);
1361 static int param_get_aabool(char *buffer
, const struct kernel_param
*kp
)
1363 if (!apparmor_enabled
)
1365 if (apparmor_initialized
&& !policy_view_capable(NULL
))
1367 return param_get_bool(buffer
, kp
);
1370 static int param_set_aauint(const char *val
, const struct kernel_param
*kp
)
1374 if (!apparmor_enabled
)
1376 /* file is ro but enforce 2nd line check */
1377 if (apparmor_initialized
)
1380 error
= param_set_uint(val
, kp
);
1381 pr_info("AppArmor: buffer size set to %d bytes\n", aa_g_path_max
);
1386 static int param_get_aauint(char *buffer
, const struct kernel_param
*kp
)
1388 if (!apparmor_enabled
)
1390 if (apparmor_initialized
&& !policy_view_capable(NULL
))
1392 return param_get_uint(buffer
, kp
);
1395 static int param_get_audit(char *buffer
, struct kernel_param
*kp
)
1397 if (!apparmor_enabled
)
1399 if (apparmor_initialized
&& !policy_view_capable(NULL
))
1401 return sprintf(buffer
, "%s", audit_mode_names
[aa_g_audit
]);
1404 static int param_set_audit(const char *val
, struct kernel_param
*kp
)
1408 if (!apparmor_enabled
)
1412 if (apparmor_initialized
&& !policy_admin_capable(NULL
))
1415 for (i
= 0; i
< AUDIT_MAX_INDEX
; i
++) {
1416 if (strcmp(val
, audit_mode_names
[i
]) == 0) {
1425 static int param_get_mode(char *buffer
, struct kernel_param
*kp
)
1427 if (!apparmor_enabled
)
1429 if (apparmor_initialized
&& !policy_view_capable(NULL
))
1432 return sprintf(buffer
, "%s", aa_profile_mode_names
[aa_g_profile_mode
]);
1435 static int param_set_mode(const char *val
, struct kernel_param
*kp
)
1439 if (!apparmor_enabled
)
1443 if (apparmor_initialized
&& !policy_admin_capable(NULL
))
1446 for (i
= 0; i
< APPARMOR_MODE_NAMES_MAX_INDEX
; i
++) {
1447 if (strcmp(val
, aa_profile_mode_names
[i
]) == 0) {
1448 aa_g_profile_mode
= i
;
1457 * AppArmor init functions
1461 * set_init_ctx - set a task context and profile on the first task.
1463 * TODO: allow setting an alternate profile than unconfined
1465 static int __init
set_init_ctx(void)
1467 struct cred
*cred
= (struct cred
*)current
->real_cred
;
1468 struct aa_task_ctx
*ctx
;
1470 lsm_early_cred(cred
);
1471 ctx
= apparmor_cred(cred
);
1473 ctx
->label
= aa_get_label(ns_unconfined(root_ns
));
1478 static void destroy_buffers(void)
1482 for_each_possible_cpu(i
) {
1483 for_each_cpu_buffer(j
) {
1484 kfree(per_cpu(aa_buffers
, i
).buf
[j
]);
1485 per_cpu(aa_buffers
, i
).buf
[j
] = NULL
;
1490 static int __init
alloc_buffers(void)
1494 for_each_possible_cpu(i
) {
1495 for_each_cpu_buffer(j
) {
1498 if (cpu_to_node(i
) > num_online_nodes())
1499 /* fallback to kmalloc for offline nodes */
1500 buffer
= kmalloc(aa_g_path_max
, GFP_KERNEL
);
1502 buffer
= kmalloc_node(aa_g_path_max
, GFP_KERNEL
,
1508 per_cpu(aa_buffers
, i
).buf
[j
] = buffer
;
1515 #ifdef CONFIG_SYSCTL
1516 static int apparmor_dointvec(struct ctl_table
*table
, int write
,
1517 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1519 if (!policy_admin_capable(NULL
))
1521 if (!apparmor_enabled
)
1524 return proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
1527 static struct ctl_path apparmor_sysctl_path
[] = {
1528 { .procname
= "kernel", },
1532 static struct ctl_table apparmor_sysctl_table
[] = {
1534 .procname
= "unprivileged_userns_apparmor_policy",
1535 .data
= &unprivileged_userns_apparmor_policy
,
1536 .maxlen
= sizeof(int),
1538 .proc_handler
= apparmor_dointvec
,
1543 static int __init
apparmor_init_sysctl(void)
1545 return register_sysctl_paths(apparmor_sysctl_path
,
1546 apparmor_sysctl_table
) ? 0 : -ENOMEM
;
1549 static inline int apparmor_init_sysctl(void)
1553 #endif /* CONFIG_SYSCTL */
1555 static int __init
apparmor_init(void)
1561 if (apparmor_enabled
&&
1562 security_module_enable("apparmor",
1563 IS_ENABLED(CONFIG_SECURITY_APPARMOR_STACKED
)))
1564 security_add_blobs(&apparmor_blob_sizes
);
1569 if (!apparmor_enabled
||
1570 !security_module_enable("apparmor",
1571 IS_ENABLED(CONFIG_SECURITY_APPARMOR_STACKED
))) {
1572 aa_info_message("AppArmor disabled by boot time parameter");
1573 apparmor_enabled
= 0;
1577 error
= aa_setup_dfa_engine();
1579 AA_ERROR("Unable to setup dfa engine\n");
1583 error
= aa_alloc_root_ns();
1585 AA_ERROR("Unable to allocate default profile namespace\n");
1589 error
= apparmor_init_sysctl();
1591 AA_ERROR("Unable to register sysctls\n");
1596 error
= alloc_buffers();
1598 AA_ERROR("Unable to allocate work buffers\n");
1602 error
= set_init_ctx();
1604 AA_ERROR("Failed to set context on init task\n");
1608 security_add_hooks(apparmor_hooks
, ARRAY_SIZE(apparmor_hooks
),
1611 /* Report that AppArmor successfully initialized */
1612 apparmor_initialized
= 1;
1613 if (aa_g_profile_mode
== APPARMOR_COMPLAIN
)
1614 aa_info_message("AppArmor initialized: complain mode enabled");
1615 else if (aa_g_profile_mode
== APPARMOR_KILL
)
1616 aa_info_message("AppArmor initialized: kill mode enabled");
1618 aa_info_message("AppArmor initialized");
1627 aa_teardown_dfa_engine();
1629 apparmor_enabled
= 0;
1633 security_initcall(apparmor_init
);