diff options
| author | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2026-11-18 08:47:30 +0900 |
|---|---|---|
| committer | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2026-11-22 10:37:22 +0900 |
| commit | a89ca0d6e5c03f1b9fcd076fa0cef2c2505b6aab (patch) | |
| tree | fe78e33fc7d1e1cc8b33fc043dd580325269ecae /tools/perf/scripts/python | |
| parent | aebb7274476403040d582c61478df8f4a7bf9cd3 (diff) | |
bootconfig: Exclude alignment padding from bootconfig max size
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.
Link: https://lore.kernel.org/all/179495925054.237695.2777053796977822521.stgit@devnote2/
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>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
