Skip to content

Commit 5746f05

Browse files
schnhrringomolnar
authored andcommitted
x86/boot: Provide more slack space during decompression
The current slack space is not enough for LZ4, which has a worst case overhead of 0.4% for data that cannot be further compressed. With an LZ4 compressed kernel with an embedded initrd, the output is likely to overwrite the input. Increase the slack space to avoid that. Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1503842124-29718-1-git-send-email-jschoenh@amazon.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent eaa2f87 commit 5746f05

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

arch/x86/boot/header.S

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,14 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
520520
# the description in lib/decompressor_xxx.c for specific information.
521521
#
522522
# extra_bytes = (uncompressed_size >> 12) + 65536 + 128
523+
#
524+
# LZ4 is even worse: data that cannot be further compressed grows by 0.4%,
525+
# or one byte per 256 bytes. OTOH, we can safely get rid of the +128 as
526+
# the size-dependent part now grows so fast.
527+
#
528+
# extra_bytes = (uncompressed_size >> 8) + 65536
523529

524-
#define ZO_z_extra_bytes ((ZO_z_output_len >> 12) + 65536 + 128)
530+
#define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 65536)
525531
#if ZO_z_output_len > ZO_z_input_len
526532
# define ZO_z_extract_offset (ZO_z_output_len + ZO_z_extra_bytes - \
527533
ZO_z_input_len)

0 commit comments

Comments
 (0)