Skip to content

Commit 27cb657

Browse files
CVE-2025-1272: security: Re-enable lockdown LSM in some setup_arch()
JIRA: https://issues.redhat.com/browse/RHEL-78974 CVE: CVE-2025-1272 Upstream Status: RHEL-only Restore the functionality of the lockdown LSM routines in the architecture-specific setup_arch() routines for x86, s390, powerpc, and arm64. Calls to the LSM lockdown routines security_lock_kernel_down() and security_locked_down() are ineffective prior to a call to early_security_init(). And commit 77b644c ("init/main.c: Initialize early LSMs after arch code, static keys and calls") moved the call to early_security_init() in start_kernel() from before the call to setup_arch() to after it. Secondly, even if lock_kernel_down() is called directly, e.g. via the kernel parameter lockdown, or CONFIG_LOCK_DOWN_KERNEL_FORCE_*, security_locked_down() will return false until early_security_init() is called. An example of such an early call occurs in acpi_table_upgrade() if CONFIG_ACPI_TABLE_UPGRADE is enabled. Fix this by calling early_security_init() in the arch-specifc setup_arch() routines that depend on early enablement of the lockdown LSM. First, make it safe to call early_security_init() more than once. All subsequent calls do nothing. Then add a call to early_security_init() into the x86, s390, and powerpc, and arm64 versions of setup_arch(). Both static_call_init() and jump_table_init() are prerequisites for early_security_init(). So add or move them accordingly. All three of these routines can be safely called more than once. Tested: Kernel lockdown tested on x86_64, s390x, ppc64le, and arm64. Fixes: 77b644c ("init/main.c: Initialize early LSMs after arch code, static keys and calls") Signed-off-by: Lenny Szubowicz <[email protected]>
1 parent 5150d3a commit 27cb657

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

arch/arm64/kernel/setup.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/psci.h>
3232
#include <linux/sched/task.h>
3333
#include <linux/mm.h>
34+
#include <linux/security.h>
3435

3536
#include <asm/acpi.h>
3637
#include <asm/fixmap.h>
@@ -294,6 +295,10 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)
294295

295296
parse_early_param();
296297

298+
/* Initialize the lockdown LSM */
299+
static_call_init();
300+
early_security_init();
301+
297302
/*
298303
* The primary CPU enters the kernel with all DAIF exceptions masked.
299304
*

arch/powerpc/kernel/setup-common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,11 @@ void __init setup_arch(char **cmdline_p)
870870
*/
871871
initialize_cache_info();
872872

873+
/* Initialize the lockdown LSM */
874+
jump_label_init();
875+
static_call_init();
876+
early_security_init();
877+
873878
/*
874879
* Lock down the kernel if booted in secure mode. This is required to
875880
* maintain kernel integrity.

arch/s390/kernel/setup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,11 @@ void __init setup_arch(char **cmdline_p)
892892

893893
log_component_list();
894894

895+
/* Initialize the lockdown LSM */
896+
jump_label_init();
897+
static_call_init();
898+
early_security_init();
899+
895900
if (ipl_get_secureboot())
896901
security_lock_kernel_down("Secure IPL mode", LOCKDOWN_INTEGRITY_MAX);
897902

@@ -906,7 +911,6 @@ void __init setup_arch(char **cmdline_p)
906911
if (IS_ENABLED(CONFIG_EXPOLINE_AUTO))
907912
nospec_auto_detect();
908913

909-
jump_label_init();
910914
parse_early_param();
911915
#ifdef CONFIG_CRASH_DUMP
912916
/* Deactivate elfcorehdr= kernel parameter */

arch/x86/kernel/setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,11 @@ void __init setup_arch(char **cmdline_p)
838838

839839
idt_setup_early_traps();
840840
early_cpu_init();
841+
842+
/* Initialize the lockdown LSM */
841843
jump_label_init();
842844
static_call_init();
845+
early_security_init();
843846
early_ioremap_init();
844847

845848
setup_olpc_ofw_pgd();

security/security.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ static void __init ordered_lsm_init(void)
477477
int __init early_security_init(void)
478478
{
479479
struct lsm_info *lsm;
480+
static bool early_security_initialized;
481+
482+
if (early_security_initialized)
483+
return 0;
480484

481485
for (lsm = __start_early_lsm_info; lsm < __end_early_lsm_info; lsm++) {
482486
if (!lsm->enabled)
@@ -485,6 +489,7 @@ int __init early_security_init(void)
485489
initialize_lsm(lsm);
486490
}
487491

492+
early_security_initialized = true;
488493
return 0;
489494
}
490495

0 commit comments

Comments
 (0)