Skip to content

Commit 24ed334

Browse files
committed
Merge branch 'next-loadpin' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull LoadPin updates from James Morris: "From Kees: This is a small reporting improvement and the param change needed for the ordering series (but since the loadpin change is desired and separable, I'm putting it here)" * 'next-loadpin' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: LoadPin: Rename boot param "enabled" to "enforce" LoadPin: Report friendly block device name
2 parents e80bc22 + 85a5859 commit 24ed334

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

security/loadpin/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ config SECURITY_LOADPIN
1010
have a root filesystem backed by a read-only device such as
1111
dm-verity or a CDROM.
1212

13-
config SECURITY_LOADPIN_ENABLED
13+
config SECURITY_LOADPIN_ENFORCE
1414
bool "Enforce LoadPin at boot"
1515
depends on SECURITY_LOADPIN
1616
help
1717
If selected, LoadPin will enforce pinning at boot. If not
1818
selected, it can be enabled at boot with the kernel parameter
19-
"loadpin.enabled=1".
19+
"loadpin.enforce=1".

security/loadpin/loadpin.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void report_load(const char *origin, struct file *file, char *operation)
4444
kfree(pathname);
4545
}
4646

47-
static int enabled = IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENABLED);
47+
static int enforce = IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENFORCE);
4848
static struct super_block *pinned_root;
4949
static DEFINE_SPINLOCK(pinned_root_spinlock);
5050

@@ -60,8 +60,8 @@ static struct ctl_path loadpin_sysctl_path[] = {
6060

6161
static struct ctl_table loadpin_sysctl_table[] = {
6262
{
63-
.procname = "enabled",
64-
.data = &enabled,
63+
.procname = "enforce",
64+
.data = &enforce,
6565
.maxlen = sizeof(int),
6666
.mode = 0644,
6767
.proc_handler = proc_dointvec_minmax,
@@ -84,8 +84,11 @@ static void check_pinning_enforcement(struct super_block *mnt_sb)
8484
* device, allow sysctl to change modes for testing.
8585
*/
8686
if (mnt_sb->s_bdev) {
87+
char bdev[BDEVNAME_SIZE];
88+
8789
ro = bdev_read_only(mnt_sb->s_bdev);
88-
pr_info("dev(%u,%u): %s\n",
90+
bdevname(mnt_sb->s_bdev, bdev);
91+
pr_info("%s (%u:%u): %s\n", bdev,
8992
MAJOR(mnt_sb->s_bdev->bd_dev),
9093
MINOR(mnt_sb->s_bdev->bd_dev),
9194
ro ? "read-only" : "writable");
@@ -97,7 +100,7 @@ static void check_pinning_enforcement(struct super_block *mnt_sb)
97100
loadpin_sysctl_table))
98101
pr_notice("sysctl registration failed!\n");
99102
else
100-
pr_info("load pinning can be disabled.\n");
103+
pr_info("enforcement can be disabled.\n");
101104
} else
102105
pr_info("load pinning engaged.\n");
103106
}
@@ -128,7 +131,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id)
128131

129132
/* This handles the older init_module API that has a NULL file. */
130133
if (!file) {
131-
if (!enabled) {
134+
if (!enforce) {
132135
report_load(origin, NULL, "old-api-pinning-ignored");
133136
return 0;
134137
}
@@ -151,7 +154,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id)
151154
* Unlock now since it's only pinned_root we care about.
152155
* In the worst case, we will (correctly) report pinning
153156
* failures before we have announced that pinning is
154-
* enabled. This would be purely cosmetic.
157+
* enforcing. This would be purely cosmetic.
155158
*/
156159
spin_unlock(&pinned_root_spinlock);
157160
check_pinning_enforcement(pinned_root);
@@ -161,7 +164,7 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id)
161164
}
162165

163166
if (IS_ERR_OR_NULL(pinned_root) || load_root != pinned_root) {
164-
if (unlikely(!enabled)) {
167+
if (unlikely(!enforce)) {
165168
report_load(origin, file, "pinning-ignored");
166169
return 0;
167170
}
@@ -186,10 +189,11 @@ static struct security_hook_list loadpin_hooks[] __lsm_ro_after_init = {
186189

187190
void __init loadpin_add_hooks(void)
188191
{
189-
pr_info("ready to pin (currently %sabled)", enabled ? "en" : "dis");
192+
pr_info("ready to pin (currently %senforcing)\n",
193+
enforce ? "" : "not ");
190194
security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
191195
}
192196

193197
/* Should not be mutable after boot, so not listed in sysfs (perm == 0). */
194-
module_param(enabled, int, 0);
195-
MODULE_PARM_DESC(enabled, "Pin module/firmware loading (default: true)");
198+
module_param(enforce, int, 0);
199+
MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning");

0 commit comments

Comments
 (0)