Re: [PATCH 2/2] bootconfig: Free the initrd memory used by bootconfig

From: Breno Leitao

Date: Fri Nov 20 2026 - 13:47:23 EST


On Wed, Nov 18, 2026 at 08:47:40AM +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> get_boot_config_from_initrd() removes the bootconfig from the initrd by
> decrementing initrd_end in place. However, the whole initrd including
> the bootconfig is reserved, e.g. reserve_initrd_mem() reserves
> [initrd_start, PAGE_ALIGN(original initrd_end)), and do_populate_rootfs()
> frees it with free_initrd_mem(initrd_start, initrd_end). Thus the full
> pages in [PAGE_ALIGN(new initrd_end), PAGE_ALIGN(original initrd_end))
> are never freed. This leaks up to 8 pages for a 32KB bootconfig.
>
> Save the original initrd_end in initrd_mem_end when trimming the
> bootconfig, and restore initrd_end before freeing the initrd memory.
> The bootconfig data has already been copied by xbc_init() at that point.
> The trimmed initrd_end is kept when the initrd is retained, so that
> /sys/firmware/initrd does not expose the bootconfig.
>
> Fixes: de462e5f1071 ("bootconfig: Fix to remove bootconfig data from initrd while boot")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

Reviewed-by: Breno Leitao <leitao@xxxxxxxxxx>