From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
Breno Leitao <leitao@debian.org>,
Ryan Roberts <ryan.roberts@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org
Subject: [PATCH 0/2] bootconfig: Fix max size padding and initrd memory leak
Date: Wed, 18 Nov 2026 08:47:20 +0900 [thread overview]
Message-ID: <179495924003.237695.10973676765152260584.stgit@devnote2> (raw)
Hi,
Here are 2 patches to fix pre-existing bootconfig issues around the
bootconfig attached to the initrd image.
[1/2] fixes the bootconfig loader in both the kernel and the bootconfig
tool to exclude the 4-byte alignment padding from the maximum bootconfig
size check. When attaching a bootconfig to an initrd image, the tool
appends 0-3 null padding bytes and includes them in the footer size
field. Although the documentation states that the maximum size (32767
bytes including the terminal null) does not include these padding null
bytes, both the kernel and the tool checked the raw footer size directly
against XBC_DATA_MAX, rejecting a maximum-size bootconfig depending on
the initrd size. This allows up to 3 trailing null padding bytes in the
footer size and strips them before checking XBC_DATA_MAX and parsing.
[2/2] fixes a memory leak of the initrd pages used by the bootconfig.
get_boot_config_from_initrd() trims the bootconfig by decrementing
initrd_end, but the initrd memory is freed with the trimmed initrd_end
while the whole initrd including the bootconfig has been reserved.
Thus the full pages used only by the bootconfig are never freed (up to
8 pages for a 32KB bootconfig). This saves the original initrd_end and
restores it before freeing the initrd memory. If the initrd is retained,
the trimmed initrd_end is kept so that /sys/firmware/initrd does not
expose the bootconfig.
Thank you,
---
base-commit: 381b391bfaa3f10d52da4740529804b0b6b8160d
Masami Hiramatsu (Google) (2):
bootconfig: Exclude alignment padding from bootconfig max size
bootconfig: Free the initrd memory used by bootconfig
include/linux/bootconfig.h | 24 ++++++++++++++++++++++++
include/linux/initrd.h | 2 ++
init/initramfs.c | 10 ++++++++++
init/main.c | 31 ++++++++++++++++++++++---------
tools/bootconfig/main.c | 14 ++++++++++----
tools/bootconfig/test-bootconfig.sh | 17 +++++++++++++++--
6 files changed, 83 insertions(+), 15 deletions(-)
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next reply other threads:[~2026-11-17 23:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 23:47 Masami Hiramatsu (Google) [this message]
2026-11-17 23:47 ` [PATCH 1/2] bootconfig: Exclude alignment padding from bootconfig max size Masami Hiramatsu (Google)
2026-11-17 23:47 ` [PATCH 2/2] bootconfig: Free the initrd memory used by bootconfig Masami Hiramatsu (Google)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179495924003.237695.10973676765152260584.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=leitao@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox