Skip to content

Commit 447f20a

Browse files
bwhacksPlaidCat
authored andcommitted
mtd: phram,slram: Disable when the kernel is locked down
jira LE-2629 feature Additional SecureBoot patches for dynamic lockdown commit 78c8af872660c31779951583b6f1ebf283d95985 commit-source https://salsa.debian.org/kernel-team/linux.git commit-patch-path debian/patches/features/all/lockdown commit-info Checkout the commit sha above and move to the directory listed above to find Debian patches matching this commits summary line. These drivers allow mapping arbitrary memory ranges as MTD devices. This should be disabled to preserve the kernel's integrity when it is locked down. * Add the HWPARAM flag to the module parameters * When slram is built-in, it uses __setup() to read kernel parameters, so add an explicit check security_locked_down() check Signed-off-by: Ben Hutchings <[email protected]> Cc: Matthew Garrett <[email protected]> Cc: David Howells <[email protected]> Cc: Joern Engel <[email protected]> Cc: [email protected] Signed-off-by: Jonathan Maple <[email protected]>
1 parent 39b66a2 commit 447f20a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/mtd/devices/phram.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,11 @@ static int phram_param_call(const char *val, const struct kernel_param *kp)
364364
#endif
365365
}
366366

367-
module_param_call(phram, phram_param_call, NULL, NULL, 0200);
367+
static const struct kernel_param_ops phram_param_ops = {
368+
.set = phram_param_call
369+
};
370+
__module_param_call(MODULE_PARAM_PREFIX, phram, &phram_param_ops, NULL,
371+
0200, -1, KERNEL_PARAM_FL_HWPARAM | hwparam_iomem);
368372
MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>[,<erasesize>]\"");
369373

370374
#ifdef CONFIG_OF

drivers/mtd/devices/slram.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/ioctl.h>
4444
#include <linux/init.h>
4545
#include <linux/io.h>
46+
#include <linux/security.h>
4647

4748
#include <linux/mtd/mtd.h>
4849

@@ -65,7 +66,7 @@ typedef struct slram_mtd_list {
6566
#ifdef MODULE
6667
static char *map[SLRAM_MAX_DEVICES_PARAMS];
6768

68-
module_param_array(map, charp, NULL, 0);
69+
module_param_hw_array(map, charp, iomem, NULL, 0);
6970
MODULE_PARM_DESC(map, "List of memory regions to map. \"map=<name>, <start>, <length / end>\"");
7071
#else
7172
static char *map;
@@ -281,11 +282,17 @@ static int __init init_slram(void)
281282
#ifndef MODULE
282283
char *devstart;
283284
char *devlength;
285+
int ret;
284286

285287
if (!map) {
286288
E("slram: not enough parameters.\n");
287289
return(-EINVAL);
288290
}
291+
292+
ret = security_locked_down(LOCKDOWN_MODULE_PARAMETERS);
293+
if (ret)
294+
return ret;
295+
289296
while (map) {
290297
devname = devstart = devlength = NULL;
291298

0 commit comments

Comments
 (0)