mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] bootconfig: Fix max size padding and initrd memory leak
@ 2026-11-17 23:47 Masami Hiramatsu (Google)
  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)
  0 siblings, 2 replies; 3+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-11-17 23:47 UTC (permalink / raw)
  To: Masami Hiramatsu, Andrew Morton, Christian Brauner
  Cc: Alexander Viro, Jan Kara, Breno Leitao, Ryan Roberts,
	Steven Rostedt, linux-kernel, linux-fsdevel, linux-trace-kernel

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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-17 23:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 23:47 [PATCH 0/2] bootconfig: Fix max size padding and initrd memory leak Masami Hiramatsu (Google)
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)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®