Re: [PATCH v5 04/21] x86, boot: Move compressed kernel to end of decompression buffer

From: Ingo Molnar
Date: Fri Apr 15 2016 - 05:05:27 EST



* Kees Cook <keescook@xxxxxxxxxxxx> wrote:

> When INIT_SIZE is bigger than VO_INIT_SIZE (uncommon but possible),
> the copied ZO occupies the memory from extract_offset to the end of
> decompression buffer. It overlaps with the soon-to-be-uncompressed kernel
> like this:
>
> |-----compressed kernel image------|
> V V
> 0 extract_offset +INIT_SIZE
> |-----------|---------------|-------------------------|--------|
> | | | |
> VO__text startup_32 of ZO VO__end ZO__end
> ^ ^
> |-------uncompressed kernel image---------|
>
> When INIT_SIZE is equal to VO_INIT_SIZE (likely) there's still space
> left from end of ZO to the end of decompressing buffer, like below.
>
> |-compressed kernel image-|
> V V
> 0 extract_offset +INIT_SIZE
> |-----------|---------------|-------------------------|--------|
> | | | |
> VO__text startup_32 of ZO ZO__end VO__end
> ^ ^
> |------------uncompressed kernel image-------------|
>
> To simplify calculations and avoid special cases, it is cleaner to
> always place the compressed kernel image in memory so that ZO__end
> is at the end of the decompression buffer, instead of placing that
> start extract_offset as is currently done.

Btw., it would be nice to also put such a visualization (of the current layout of
these values) into the code itself.

Thanks,

Ingo