From nobody Sun Feb 8 01:33:30 2026 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4D3E2F1FC7 for ; Tue, 13 Jan 2026 10:16:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299364; cv=none; b=hwirZyHVXuqNY3yXVYMH5CV7zUGcMycJkZuwjqIVJLdSuTl+GEgfOjK8aX69+h4+PDO6FPFRSYY/YLG1hdMJ/lzhLaPKkDm0f0IbtYzsA2N1hRCDxSTsq7ZzwVGx3cF9g8sJTwDB/0RRRqUtNfabD2yYyui8zkTbn+6sQWHOx1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299364; c=relaxed/simple; bh=KygkyM1yq2AW+e032EsSZ4zDXd9VRg1nzbMfFRywoO0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MOTH4mYxciYSN5zNhlfr2zvwRaL6iMgtPF7/B3TB6uB1qtOaQJQW55UEuoVdZDTFblCGYmrpJtng7gNRwsp0Jk+az+hbzrTBPgHFJ1MLUaPNqycMMxCYB+L+htJw6p4/K51/KkkdTt+AtIFzmTc5KR13iOFM3G+FXoTqGu7WK00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R82B9uFu; arc=none smtp.client-ip=74.125.82.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R82B9uFu" Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-2b04fcfc0daso7593310eec.0 for ; Tue, 13 Jan 2026 02:16:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768299361; x=1768904161; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Qgckjd2aTgcTXkeoTwXzPXLau6Bio5+6ZUNg2Pglyt4=; b=R82B9uFuYu0XH77+HBs17Lv3EYETP+ZfqH86O/oDYId03PZG/wh6uOLKMpNSOjNWxy ApL68ZycB0P/CbGdSetqnOqOnoNVqqJY/4i5N3DYX4qP4P0a4X8hdHFPHgdwZdiIQSnJ mn2MeFWpiBaHVvqfGC26O+3zanxi0McJ7RbB02md1KdXGqHHm/7glxcUEbg5WhJQOtEr 6hDr9neg4UEjzPB9lFUWM13vDm3AT6GDumbKcGwTFzj5homhTEomb0UpxJFNfZfXSvn/ aHA6zfZITYZEPN+xtljRYr858gtp7oAac8A/5xigS9KeTIUctoIS1fnL3LYiTSgAf+7h 16ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768299361; x=1768904161; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Qgckjd2aTgcTXkeoTwXzPXLau6Bio5+6ZUNg2Pglyt4=; b=K9tICeut35sp42x2tscl7zO0yMFIBsNcjyWgRrCDIuyTHUGQ5jqrzEwjESUAdaZwdM gE9ggGiDZjqptjl99zhw3ZXIYx1EouCKKTv/4orgTyaUFn9yGZ905lY/L2FAp2fgmbXg Z9ZOi5rsQHA2hftNitCWy8CHZn+zJGcB4G/aQn5+iqmsPoFqu8qvgico6SbEoZAh6Ne1 sslKysM4N1nylQCNOfhkPKSZsTItIE4XqmG6EC0rFDYScsuoBJT2Jm5u0ApHxcKn1HwN 4B5893kw0OQ5JBbfxkWobAFhfAzWuwL/ofiNib4f8kz8XDXeTWAamC6heZTMgCs9f+v4 wopA== X-Gm-Message-State: AOJu0Yzo5S+Sg6qzdIruw9zv8fp0mbHttZeNjy+s+LQkla/e5cL47Ayy 01tXioG+tUP/LQKK1uhU2tF3IeMuUvAypXYH8YRmuk4w+xT1EAvu3XXl X-Gm-Gg: AY/fxX6B4ZYL+F7HioiGYHtVA8zOwsEiQkIJu7M3WPInlRF7CxutUUW0owE1IpuVwR9 Vif69ZSbXcO9c8s6NFyzJySn/TLvZJYjcGht+959JkT6CNp27t9HavFrpfWj/hcU+crH7FiyIn5 zYecjRDgvSoNSGJxVWGvoTRZWj1+W+rPtX5ZtDaf9jtV6ULKdS7DsWrk/YqlvD5LMTYz6vSNEre Mkmv4yNEKD7aRY6XhJsp+Uzq1YzhJ7eo1PH4F3xY/3m4jm3hu1GnBgTh3m+3HBV6WMr5Rx8CFkZ EmI/7sD1GJ09ag+URmyr4khqo9DqQWB0NOn9XPbalQcR2KjVXnRV78r32iabObJVcLBin+zCoS3 4moVSYl2QHgIatumuD66AKJD0OwxvtvthJ8Zg5TjnbZ8CGIjavxgtfk0gYNbvu07/NelC3p+6wQ uRxJupg8DP2pD9Eoaf0rXOLw2IB6xD4HwAwxPcTTZPmIpo8mXwLrYb+cG8jjA6MBq+jAa1juWIF jQ54ir61XLE9Q== X-Google-Smtp-Source: AGHT+IGAR1sPGALFRAsA2hPuxSZjVG7eeHl6WjE5ZmuZRJwyNjKfK6bymy/0dCHWfJNGVf6kVVuaxg== X-Received: by 2002:a05:7300:3724:b0:2a4:3594:72e3 with SMTP id 5a478bee46e88-2b17d252215mr18240232eec.18.1768299361170; Tue, 13 Jan 2026 02:16:01 -0800 (PST) Received: from localhost.localdomain (108-214-96-168.lightspeed.sntcca.sbcglobal.net. [108.214.96.168]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b17052dbc7sm17305787eec.0.2026.01.13.02.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 02:16:00 -0800 (PST) From: Sun Jian To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, tglx@kernel.org, mingo@kernel.org, rppt@kernel.org, Sun Jian Subject: [PATCH] init/main: read bootconfig header with get_unaligned_le32() Date: Tue, 13 Jan 2026 18:15:32 +0800 Message-ID: <20260113101532.1630770-1-sun.jian.kdev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D1): init/main.c:292:16: warning: cast to restricted __le32 init/main.c:293:16: warning: cast to restricted __le32 No functional change intended. Signed-off-by: Sun Jian --- init/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/init/main.c b/init/main.c index b84818ad9685..8774ad5ab8c5 100644 --- a/init/main.c +++ b/init/main.c @@ -104,6 +104,7 @@ #include #include #include +#include #include =20 #include @@ -269,7 +270,7 @@ static void * __init get_boot_config_from_initrd(size_t= *_size) { u32 size, csum; char *data; - u32 *hdr; + u8 *hdr; int i; =20 if (!initrd_end) @@ -288,9 +289,9 @@ static void * __init get_boot_config_from_initrd(size_t= *_size) return NULL; =20 found: - hdr =3D (u32 *)(data - 8); - size =3D le32_to_cpu(hdr[0]); - csum =3D le32_to_cpu(hdr[1]); + hdr =3D (u8 *)(data - 8); + size =3D get_unaligned_le32(hdr); + csum =3D get_unaligned_le32(hdr + 4); =20 data =3D ((void *)hdr) - size; if ((unsigned long)data < initrd_start) { --=20 2.43.0