ALT Linux kernel packages development
 help / color / mirror / Atom feed
From: Vitaly Chikunov <vt@altlinux.org>
To: ALT Linux kernel packages development <devel-kernel@lists.altlinux.org>
Subject: Re: [d-kernel] [PATCH 1/6] mtd: phram, slram: Disable when the kernel is locked down
Date: Sat, 9 May 2026 02:43:27 +0300
Message-ID: <af5rRkWhkTklt9Ro@altlinux.org> (raw)
In-Reply-To: <20260506173722.1012394-2-egori@altlinux.org>

On Wed, May 06, 2026 at 08:37:17PM +0300, Egor Ignatov wrote:
> 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>

Этот патч отсылался в апстрим ревьювился, ACKался но в итоге его так и не приняли
по неуказанной причине.

  https://lore.kernel.org/all/20190830154720.eekfjt6c4jzvlbfz@decadent.org.uk/


> ---
>  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);

1. Тут ошибка, должно быть `| hwparam_iomem & 0`, так как этот атрибут
только документирующий, а без `& 0` он начинает ошибочно устанавливать
лишний флаг (KERNEL_PARAM_FL_UNSAFE).

2. В Fedora этого патча нет.
3. В SUSE этого патча нет.
4. В апстриме есть коммит b3c782868eceb ("mtd: phram: Add the kernel
lock down check"), делающий изменения в phram.c не нужными. Но он не
затрагивает slram.c, но может быть это и не нужно.

Таким образом этот патч - наполовину хлам.

5. В Fedora эти модули не собираются

  redhat/kernel-ark | redhat/configs/common/generic/CONFIG_MTD_PHRAM:# CONFIG_MTD_PHRAM is not set
  redhat/kernel-ark | redhat/configs/common/generic/CONFIG_MTD_SLRAM:# CONFIG_MTD_SLRAM is not set

Возможно, поэтому этого патча и нет в Fedora.

От патча нужна только част относящаяся к slram.c:init_slram

>  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);

Должно быть LOCKDOWN_DEV_MEM, по аналогии с b3c782868eceb.


> +	if (ret)
> +		return ret;
> +
>  	while (map) {
>  		devname = devstart = devlength = NULL;
>  
> -- 
> 2.50.1
> 
> _______________________________________________
> devel-kernel mailing list
> devel-kernel@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel-kernel


  reply	other threads:[~2026-05-08 23:43 UTC|newest]

Thread overview: 13+ 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 ` [d-kernel] [PATCH 1/6] mtd: phram, slram: Disable when the kernel is locked down Egor Ignatov
2026-05-08 23:43   ` Vitaly Chikunov [this message]
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-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-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-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-08 23:01 ` [d-kernel] [PATCH 0/6] [7.0, 7.1] Lock down the kernel if booted in Secure Boot mode 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=af5rRkWhkTklt9Ro@altlinux.org \
    --to=vt@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