From: Breno Leitao <leitao@debian.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Jan Kara <jack@suse.cz>, 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: Re: [PATCH 1/2] bootconfig: Exclude alignment padding from bootconfig max size
Date: Fri, 20 Nov 2026 10:48:12 -0800 [thread overview]
Message-ID: <awCV4GdVIRNJN6ty@gmail.com> (raw)
In-Reply-To: <179495925054.237695.2777053796977822521.stgit@devnote2>
On Wed, Nov 18, 2026 at 08:47:30AM +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> When attaching a bootconfig to an initrd image, apply_xbc() appends 0-3
> null padding bytes to align the total image size to 4 bytes and includes
> those padding bytes in the footer size field. As documented in
> Documentation/admin-guide/bootconfig.rst, the maximum bootconfig size
> (XBC_DATA_MAX, 32767 bytes including the terminal null) is not supposed
> to include these padding null characters.
>
> However, both load_xbc_from_initrd() in tools/bootconfig and
> get_boot_config_from_initrd() / xbc_init() in the kernel check the raw
> footer size directly against XBC_DATA_MAX. As a result, a valid
> 32766-byte config (size = 32767 with the terminal null) gets a footer
> size of 32768..32770 when alignment padding is added, and is rejected
> with "bootconfig size is too big" depending on the initrd size.
>
> Define XBC_DATA_MAX_PADDED (XBC_DATA_MAX + BOOTCONFIG_ALIGN - 1) for the
> raw trailer size check, and add xbc_exclude_padding() to strip up to
> BOOTCONFIG_ALIGN - 1 trailing null padding bytes (keeping the terminal
> null byte) before checking the unpadded bootconfig size against
> XBC_DATA_MAX and passing it to xbc_init(). Keep using the raw footer
> size when truncating or trimming the initrd so that both the bootconfig
> and its alignment padding are removed.
>
> Also expand test-bootconfig.sh to verify applying, reading back, and
> deleting a maximum-size bootconfig across all 4 alignment paddings.
>
> Fixes: e1cef2d4c379 ("tools/bootconfig: Align the bootconfig applied initrd image size to 4")
> Cc: stable@vger.kernel.org
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Breno Leitao <leitao@debian.org>
next prev parent reply other threads:[~2026-11-20 18:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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-20 18:48 ` Breno Leitao [this message]
2026-11-17 23:47 ` [PATCH 2/2] bootconfig: Free the initrd memory used by bootconfig Masami Hiramatsu (Google)
2026-11-20 18:46 ` Breno Leitao
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=awCV4GdVIRNJN6ty@gmail.com \
--to=leitao@debian.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@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
all inboxes | Powered by JetHome®