diff options
author | Kees Cook <keescook@chromium.org> | 2018-09-24 17:43:59 -0400 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2018-10-18 18:29:44 -0400 |
commit | 13523bef1e2154b6d02836cd0f6c0ffc89b2eae6 (patch) | |
tree | eb769876befa1a7c81ed78748d9ccc0d3ec46501 | |
parent | f4b626d6de15149329332796e96709e0c4c84577 (diff) |
LoadPin: Rename boot param "enabled" to "enforce"
LoadPin's "enabled" setting is really about enforcement, not whether
or not the LSM is using LSM hooks. Instead, split this out so that LSM
enabling can be logically distinct from whether enforcement is happening
(for example, the pinning happens when the LSM is enabled, but the pin
is only checked when "enforce" is set). This allows LoadPin to continue
to operate sanely in test environments once LSM enable/disable is
centrally handled (i.e. we want LoadPin to be enabled separately from
its enforcement).
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: John Johansen <john.johansen@canonical.com>
-rw-r--r-- | security/loadpin/Kconfig | 4 | ||||
-rw-r--r-- | security/loadpin/loadpin.c | 21 |
2 files changed, 13 insertions, 12 deletions
diff --git a/security/loadpin/Kconfig b/security/loadpin/Kconfig index dd01aa91e521..a0d70d82b98e 100644 --- a/security/loadpin/Kconfig +++ b/security/loadpin/Kconfig | |||
@@ -10,10 +10,10 @@ config SECURITY_LOADPIN | |||
10 | have a root filesystem backed by a read-only device such as | 10 | have a root filesystem backed by a read-only device such as |
11 | dm-verity or a CDROM. | 11 | dm-verity or a CDROM. |
12 | 12 | ||
13 | config SECURITY_LOADPIN_ENABLED | 13 | config SECURITY_LOADPIN_ENFORCE |
14 | bool "Enforce LoadPin at boot" | 14 | bool "Enforce LoadPin at boot" |
15 | depends on SECURITY_LOADPIN | 15 | depends on SECURITY_LOADPIN |
16 | help | 16 | help |
17 | If selected, LoadPin will enforce pinning at boot. If not | 17 | If selected, LoadPin will enforce pinning at boot. If not |
18 | selected, it can be enabled at boot with the kernel parameter | 18 | selected, it can be enabled at boot with the kernel parameter |
19 | "loadpin.enabled=1". | 19 | "loadpin.enforce=1". |
diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c index f062672d6b35..48f39631b370 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c | |||
@@ -44,7 +44,7 @@ static void report_load(const char *origin, struct file *file, char *operation) | |||
44 | kfree(pathname); | 44 | kfree(pathname); |
45 | } | 45 | } |
46 | 46 | ||
47 | static int enabled = IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENABLED); | 47 | static int enforce = IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENFORCE); |
48 | static struct super_block *pinned_root; | 48 | static struct super_block *pinned_root; |
49 | static DEFINE_SPINLOCK(pinned_root_spinlock); | 49 | static DEFINE_SPINLOCK(pinned_root_spinlock); |
50 | 50 | ||
@@ -60,8 +60,8 @@ static struct ctl_path loadpin_sysctl_path[] = { | |||
60 | 60 | ||
61 | static struct ctl_table loadpin_sysctl_table[] = { | 61 | static struct ctl_table loadpin_sysctl_table[] = { |
62 | { | 62 | { |
63 | .procname = "enabled", | 63 | .procname = "enforce", |
64 | .data = &enabled, | 64 | .data = &enforce, |
65 | .maxlen = sizeof(int), | 65 | .maxlen = sizeof(int), |
66 | .mode = 0644, | 66 | .mode = 0644, |
67 | .proc_handler = proc_dointvec_minmax, | 67 | .proc_handler = proc_dointvec_minmax, |
@@ -100,7 +100,7 @@ static void check_pinning_enforcement(struct super_block *mnt_sb) | |||
100 | loadpin_sysctl_table)) | 100 | loadpin_sysctl_table)) |
101 | pr_notice("sysctl registration failed!\n"); | 101 | pr_notice("sysctl registration failed!\n"); |
102 | else | 102 | else |
103 | pr_info("load pinning can be disabled.\n"); | 103 | pr_info("enforcement can be disabled.\n"); |
104 | } else | 104 | } else |
105 | pr_info("load pinning engaged.\n"); | 105 | pr_info("load pinning engaged.\n"); |
106 | } | 106 | } |
@@ -131,7 +131,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) | |||
131 | 131 | ||
132 | /* This handles the older init_module API that has a NULL file. */ | 132 | /* This handles the older init_module API that has a NULL file. */ |
133 | if (!file) { | 133 | if (!file) { |
134 | if (!enabled) { | 134 | if (!enforce) { |
135 | report_load(origin, NULL, "old-api-pinning-ignored"); | 135 | report_load(origin, NULL, "old-api-pinning-ignored"); |
136 | return 0; | 136 | return 0; |
137 | } | 137 | } |
@@ -154,7 +154,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) | |||
154 | * Unlock now since it's only pinned_root we care about. | 154 | * Unlock now since it's only pinned_root we care about. |
155 | * In the worst case, we will (correctly) report pinning | 155 | * In the worst case, we will (correctly) report pinning |
156 | * failures before we have announced that pinning is | 156 | * failures before we have announced that pinning is |
157 | * enabled. This would be purely cosmetic. | 157 | * enforcing. This would be purely cosmetic. |
158 | */ | 158 | */ |
159 | spin_unlock(&pinned_root_spinlock); | 159 | spin_unlock(&pinned_root_spinlock); |
160 | check_pinning_enforcement(pinned_root); | 160 | check_pinning_enforcement(pinned_root); |
@@ -164,7 +164,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | if (IS_ERR_OR_NULL(pinned_root) || load_root != pinned_root) { | 166 | if (IS_ERR_OR_NULL(pinned_root) || load_root != pinned_root) { |
167 | if (unlikely(!enabled)) { | 167 | if (unlikely(!enforce)) { |
168 | report_load(origin, file, "pinning-ignored"); | 168 | report_load(origin, file, "pinning-ignored"); |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
@@ -189,10 +189,11 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = { | |||
189 | 189 | ||
190 | void __init loadpin_add_hooks(void) | 190 | void __init loadpin_add_hooks(void) |
191 | { | 191 | { |
192 | pr_info("ready to pin (currently %sabled)", enabled ? "en" : "dis"); | 192 | pr_info("ready to pin (currently %senforcing)\n", |
193 | enforce ? "" : "not "); | ||
193 | security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); | 194 | security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); |
194 | } | 195 | } |
195 | 196 | ||
196 | /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ | 197 | /* Should not be mutable after boot, so not listed in sysfs (perm == 0). */ |
197 | module_param(enabled, int, 0); | 198 | module_param(enforce, int, 0); |
198 | MODULE_PARM_DESC(enabled, "Pin module/firmware loading (default: true)"); | 199 | MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning"); |