From: Egor Ignatov <egori@altlinux.org>
To: devel-kernel@lists.altlinux.org
Subject: [d-kernel] [PATCH 1/6] mtd: phram, slram: Disable when the kernel is locked down
Date: Wed, 6 May 2026 20:37:17 +0300
Message-ID: <20260506173722.1012394-2-egori@altlinux.org> (raw)
In-Reply-To: <20260506173722.1012394-1-egori@altlinux.org>
From: Ben Hutchings <ben@decadent.org.uk>
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 <ben@decadent.org.uk>
Cc: Matthew Garrett <mjg59@google.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Joern Engel <joern@lazybastard.org>
Cc: linux-mtd@lists.infradead.org
[egori: imported from Debian linux package, patch
lockdown/mtd-disable-slram-and-phram-when-locked-down.patch]
Signed-off-by: Egor Ignatov <egori@altlinux.org>
---
drivers/mtd/devices/phram.c | 6 +++++-
drivers/mtd/devices/slram.c | 9 ++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index b42cadcd76..42ccabf24d 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -365,7 +365,11 @@ static int phram_param_call(const char *val, const struct kernel_param *kp)
#endif
}
-module_param_call(phram, phram_param_call, NULL, NULL, 0200);
+static const struct kernel_param_ops phram_param_ops = {
+ .set = phram_param_call
+};
+__module_param_call(MODULE_PARAM_PREFIX, phram, &phram_param_ops, NULL,
+ 0200, -1, KERNEL_PARAM_FL_HWPARAM | hwparam_iomem);
MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>[,<erasesize>]\"");
#ifdef CONFIG_OF
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 69cb63d99f..1330b47af0 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -43,6 +43,7 @@
#include <linux/ioctl.h>
#include <linux/init.h>
#include <linux/io.h>
+#include <linux/security.h>
#include <linux/mtd/mtd.h>
@@ -65,7 +66,7 @@ typedef struct slram_mtd_list {
#ifdef MODULE
static char *map[SLRAM_MAX_DEVICES_PARAMS];
-module_param_array(map, charp, NULL, 0);
+module_param_hw_array(map, charp, iomem, NULL, 0);
MODULE_PARM_DESC(map, "List of memory regions to map. \"map=<name>, <start>, <length / end>\"");
#else
static char *map;
@@ -281,11 +282,17 @@ static int __init init_slram(void)
#ifndef MODULE
char *devstart;
char *devlength;
+ int ret;
if (!map) {
E("slram: not enough parameters.\n");
return(-EINVAL);
}
+
+ ret = security_locked_down(LOCKDOWN_MODULE_PARAMETERS);
+ if (ret)
+ return ret;
+
while (map) {
devname = devstart = devlength = NULL;
--
2.50.1
next prev parent reply other threads:[~2026-05-06 17:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 17:37 [d-kernel] [PATCH 0/6] [7.0, 7.1] Lock down the kernel if booted in Secure Boot mode Egor Ignatov
2026-05-06 17:37 ` Egor Ignatov [this message]
2026-05-08 23:43 ` [d-kernel] [PATCH 1/6] mtd: phram, slram: Disable when the kernel is locked down Vitaly Chikunov
2026-05-06 17:37 ` [d-kernel] [PATCH 2/6] security: lockdown: expose security_lock_kernel_down function Egor Ignatov
2026-05-09 0:20 ` Vitaly Chikunov
2026-05-20 12:25 ` Egor Ignatov
2026-05-06 17:37 ` [d-kernel] [PATCH 3/6] efi: Add an EFI_SECURE_BOOT flag to indicate secure boot mode Egor Ignatov
2026-05-06 17:37 ` [d-kernel] [PATCH 4/6] efi: Lock down the kernel if booted in " Egor Ignatov
2026-05-09 0:24 ` Vitaly Chikunov
2026-05-20 12:28 ` Egor Ignatov
2026-05-06 17:37 ` [d-kernel] [PATCH 5/6] efi: determine and pass Secure Boot state via FDT Egor Ignatov
2026-05-09 0:28 ` Vitaly Chikunov
2026-05-20 12:29 ` Egor Ignatov
2026-05-06 17:37 ` [d-kernel] [PATCH 6/6] config: Enable LOCK_DOWN_IN_EFI_SECURE_BOOT Egor Ignatov
2026-05-09 0:34 ` Vitaly Chikunov
2026-05-20 12:29 ` Egor Ignatov
2026-05-08 23:01 ` [d-kernel] [PATCH 0/6] [7.0, 7.1] Lock down the kernel if booted in Secure Boot mode Vitaly Chikunov
2026-05-20 12:29 ` Egor Ignatov
2026-05-20 16:32 ` Vitaly Chikunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260506173722.1012394-2-egori@altlinux.org \
--to=egori@altlinux.org \
--cc=devel-kernel@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux kernel packages development
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel-kernel/0 devel-kernel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel-kernel devel-kernel/ http://lore.altlinux.org/devel-kernel \
devel-kernel@altlinux.org devel-kernel@altlinux.ru devel-kernel@altlinux.com
public-inbox-index devel-kernel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel-kernel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git