From a906f3ae4423d35c9804c8ec3a0db96ce9b54d44 Mon Sep 17 00:00:00 2001 From: Lillian Berry Date: Sun, 11 Jan 2026 07:56:35 -0500 Subject: init/main.c: check if rdinit was explicitly set before printing warning The rdinit parameter is set by default, and attempted during boot even if not specified in the command line. Only print the warning about rdinit being inaccessible if the rdinit value was found in command line; it's just noise otherwise. [akpm@linux-foundation.org: move ramdisk_execute_command_set into __initdata] Link: https://lkml.kernel.org/r/20260111125635.53682-1-lillian@star-ark.net Signed-off-by: Lillian Berry Cc: Ahmad Fatoum Cc: Alexander Shishkin Cc: Al Viro Cc: Douglas Anderson Cc: Francesco Valla Cc: Guo Weikang Cc: Huacai Chen Cc: Huan Yang Cc: Ingo Molnar Cc: "Mike Rapoport (Microsoft)" Cc: Sascha Hauer Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- init/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'init') diff --git a/init/main.c b/init/main.c index b84818ad9685..4773f3bad49c 100644 --- a/init/main.c +++ b/init/main.c @@ -162,6 +162,7 @@ static size_t initargs_offs; static char *execute_command; static char *ramdisk_execute_command = "/init"; +static bool __initdata ramdisk_execute_command_set; /* * Used to generate warnings if static_key manipulation functions are used @@ -623,6 +624,7 @@ static int __init rdinit_setup(char *str) unsigned int i; ramdisk_execute_command = str; + ramdisk_execute_command_set = true; /* See "auto" comment in init_setup */ for (i = 1; i < MAX_INIT_ARGS; i++) argv_init[i] = NULL; @@ -1699,8 +1701,9 @@ static noinline void __init kernel_init_freeable(void) int ramdisk_command_access; ramdisk_command_access = init_eaccess(ramdisk_execute_command); if (ramdisk_command_access != 0) { - pr_warn("check access for rdinit=%s failed: %i, ignoring\n", - ramdisk_execute_command, ramdisk_command_access); + if (ramdisk_execute_command_set) + pr_warn("check access for rdinit=%s failed: %i, ignoring\n", + ramdisk_execute_command, ramdisk_command_access); ramdisk_execute_command = NULL; prepare_namespace(); } -- cgit From 499f86de4f8c34e19a57daf2b6f0cba848e91994 Mon Sep 17 00:00:00 2001 From: Sun Jian Date: Tue, 13 Jan 2026 18:15:32 +0800 Subject: init/main: read bootconfig header with get_unaligned_le32() get_boot_config_from_initrd() scans up to 3 bytes before initrd_end to handle GRUB 4-byte alignment. As a result, the bootconfig header immediately preceding the magic may be unaligned. Read the size and checksum fields with get_unaligned_le32() instead of casting to u32 * and using le32_to_cpu(), avoiding potential unaligned access and silencing sparse "cast to restricted __le32" warnings. Sparse warnings (gcc + C=1): init/main.c:292:16: warning: cast to restricted __le32 init/main.c:293:16: warning: cast to restricted __le32 No functional change intended. Link: https://lkml.kernel.org/r/20260113101532.1630770-1-sun.jian.kdev@gmail.com Signed-off-by: Sun Jian Cc: Ingo Molnar Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- init/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'init') diff --git a/init/main.c b/init/main.c index 4773f3bad49c..29741049aa79 100644 --- a/init/main.c +++ b/init/main.c @@ -104,6 +104,7 @@ #include #include #include +#include #include #include @@ -270,7 +271,7 @@ static void * __init get_boot_config_from_initrd(size_t *_size) { u32 size, csum; char *data; - u32 *hdr; + u8 *hdr; int i; if (!initrd_end) @@ -289,9 +290,9 @@ static void * __init get_boot_config_from_initrd(size_t *_size) return NULL; found: - hdr = (u32 *)(data - 8); - size = le32_to_cpu(hdr[0]); - csum = le32_to_cpu(hdr[1]); + hdr = (u8 *)(data - 8); + size = get_unaligned_le32(hdr); + csum = get_unaligned_le32(hdr + 4); data = ((void *)hdr) - size; if ((unsigned long)data < initrd_start) { -- cgit