From: Takashi Iwai Date: Thu, 14 Nov 2024 15:44:41 +0000 (+0100) Subject: mtd: phram: Add the kernel lock down check X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b3c782868ecebd0c1661a6aa2bdc84cd3cbb1ef3;p=users%2Fjedix%2Flinux-maple.git mtd: phram: Add the kernel lock down check The phram MTD driver may map any memory pages no matter whether it's reserved or whatever used for systems, which basically allows user bypassing the lock down. Add the check and abort the probe if the kernel is locked down for LOCKDOWN_DEV_MEM. Reported-by: Fabian Vogt Suggested-by: Fabian Vogt Signed-off-by: Takashi Iwai Acked-by: Richard Weinberger Signed-off-by: Miquel Raynal --- diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index b8bbc7ecbe95..fd9ec165e61a 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -30,6 +30,7 @@ #include #include #include +#include struct phram_mtd_list { struct mtd_info mtd; @@ -410,6 +411,10 @@ static int __init init_phram(void) { int ret; + ret = security_locked_down(LOCKDOWN_DEV_MEM); + if (ret) + return ret; + ret = platform_driver_register(&phram_driver); if (ret) return ret;