bootconfig: Fix max size padding and initrd memory leak
Get series with b4
b4 am 179495924003.237695.10973676765152260584.stgit@devnote2Versions newest first
- v1 Latest2 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bootconfig: Exclude alignment padding from bootconfig max sizeinclude/ init/ tools/ +1 more | +64 | 1 reply | |
| 2/2 | bootconfig: Free the initrd memory used by bootconfiginclude/ init/ init/ | +19 | 1 reply |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Breno Leitao |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/2] bootconfig: Fix max size padding and initrd memory leak
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) <[email protected]>