Commit 7e6966e5 by Serge Hallyn Committed by Stéphane Graber

apparmor: cache the are-we-enabled decision

Since we check /sys/kernel/security/ files when deciding whether apparmor is enabled, and that might not be mounted in the container, we cannot re-make the decision at apparmor_process_label_set() time. Luckily we don't have to - just cache the decision made at lsm_apparmor_drv_init(). Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 33662399
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
lxc_log_define(lxc_apparmor, lxc); lxc_log_define(lxc_apparmor, lxc);
/* set by lsm_apparmor_drv_init if true */
static int aa_enabled = 0;
#define AA_DEF_PROFILE "lxc-container-default" #define AA_DEF_PROFILE "lxc-container-default"
#define AA_MOUNT_RESTR "/sys/kernel/security/apparmor/features/mount/mask" #define AA_MOUNT_RESTR "/sys/kernel/security/apparmor/features/mount/mask"
#define AA_ENABLED_FILE "/sys/module/apparmor/parameters/enabled" #define AA_ENABLED_FILE "/sys/module/apparmor/parameters/enabled"
...@@ -139,7 +142,7 @@ static int apparmor_am_unconfined(void) ...@@ -139,7 +142,7 @@ static int apparmor_am_unconfined(void)
static int apparmor_process_label_set(const char *label, int use_default, static int apparmor_process_label_set(const char *label, int use_default,
int on_exec) int on_exec)
{ {
if (!apparmor_enabled()) if (!aa_enabled)
return 0; return 0;
if (!label) { if (!label) {
...@@ -181,5 +184,6 @@ struct lsm_drv *lsm_apparmor_drv_init(void) ...@@ -181,5 +184,6 @@ struct lsm_drv *lsm_apparmor_drv_init(void)
{ {
if (!apparmor_enabled()) if (!apparmor_enabled())
return NULL; return NULL;
aa_enabled = 1;
return &apparmor_drv; return &apparmor_drv;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment