Skip to contentSkip to conversation

init-main-read-bootconfig-header-with-get_unaligned_le32.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jan 21

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: init/main: read bootconfig header with get_unaligned_le32()
has been removed from the -mm tree. Its filename was
init-main-read-bootconfig-header-with-get_unaligned_le32.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Sun Jian <[email protected]>
Subject: init/main: read bootconfig header with get_unaligned_le32()
Date: Tue, 13 Jan 2026 18:15:32 +0800

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.

---

 init/main.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
init/main.c renamed from init/main.c~init-main-read-bootconfig-header-with-get_unaligned_le32 +5 -4
@@ -104,6 +104,7 @@
 #include <linux/pidfs.h>
 #include <linux/ptdump.h>
 #include <linux/time_namespace.h>
+#include <linux/unaligned.h>
 #include <net/net_namespace.h>
 
 #include <asm/io.h>
@@ -270,7 +271,7 @@ static void * __init get_boot_config_fro
 {
 	u32 size, csum;
 	char *data;
-	u32 *hdr;
+	u8 *hdr;
 	int i;
 
 	if (!initrd_end)
@@ -289,9 +290,9 @@ static void * __init get_boot_config_fro
 	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) {

_

Patches currently in -mm which might be from [email protected] are