linux-stable/arch/x86/boot/compressed
Yinghai Lu 2d3862d26e lib/decompressors: use real out buf size for gunzip with kernel
When loading x86 64bit kernel above 4GiB with patched grub2, got kernel
gunzip error.

| early console in decompress_kernel
| decompress_kernel:
|       input: [0x807f2143b4-0x807ff61aee]
|      output: [0x807cc00000-0x807f3ea29b] 0x027ea29c: output_len
| boot via startup_64
| KASLR using RDTSC...
|  new output: [0x46fe000000-0x470138cfff] 0x0338d000: output_run_size
|  decompress: [0x46fe000000-0x47007ea29b] <=== [0x807f2143b4-0x807ff61aee]
|
| Decompressing Linux... gz...
|
| uncompression error
|
| -- System halted

the new buffer is at 0x46fe000000ULL, decompressor_gzip is using
0xffffffb901ffffff as out_len.  gunzip in lib/zlib_inflate/inflate.c cap
that len to 0x01ffffff and decompress fails later.

We could hit this problem with crashkernel booting that uses kexec loading
kernel above 4GiB.

We have decompress_* support:
    1. inbuf[]/outbuf[] for kernel preboot.
    2. inbuf[]/flush() for initramfs
    3. fill()/flush() for initrd.
This bug only affect kernel preboot path that use outbuf[].

Add __decompress and take real out_buf_len for gunzip instead of guessing
wrong buf size.

Fixes: 1431574a1c (lib/decompressors: fix "no limit" output buffer length)
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Alexandre Courbot <acourbot@nvidia.com>
Cc: Jon Medhurst <tixy@linaro.org>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-09-10 13:29:01 -07:00
..
.gitignore x86, boot: add new generated files to the appropriate .gitignore files 2009-06-02 21:13:30 -07:00
aslr.c x86/asm/tsc: Rename native_read_tsc() to rdtsc() 2015-07-06 15:23:28 +02:00
cmdline.c x86, kaslr: Return location from decompress_kernel 2013-10-13 03:12:07 -07:00
cpuflags.c x86, boot: Rename get_flags() and check_flags() to *_cpuflags() 2013-10-13 04:08:56 -07:00
early_serial_console.c x86, boot: Don't compile early_serial_console.c when !CONFIG_EARLY_PRINTK 2014-08-17 14:58:24 -07:00
eboot.c Linux 4.2-rc7 2015-08-17 10:41:59 +02:00
eboot.h efi/x86: Move x86 back to libstub 2014-11-11 22:23:11 +00:00
efi_stub_32.S x86, efi: EFI boot stub support 2011-12-12 14:26:10 -08:00
efi_stub_64.S x86/efi: Avoid triple faults during EFI mixed mode calls 2015-02-13 15:42:56 +00:00
efi_thunk_64.S x86/efi: Avoid triple faults during EFI mixed mode calls 2015-02-13 15:42:56 +00:00
head_32.S x86/asm/boot: Use already defined KEEP_SEGMENTS macro in head_{32,64}.S 2015-02-19 10:05:04 +01:00
head_64.S x86/asm/boot/64: Use __BOOT_TSS instead of literal $0x20 2015-04-02 12:00:20 +02:00
Makefile Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-02-21 10:41:29 -08:00
misc.c lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
misc.h x86/boot: Add hex output for debugging 2015-07-07 08:59:05 +02:00
mkpiggy.c x86, kaslr: Prevent .bss from overlaping initrd 2014-11-01 22:20:50 +01:00
string.c x86, boot: Remove misc.h inclusion from compressed/string.c 2014-05-08 08:00:06 -07:00
vmlinux.lds.S x86, setup: Allow global variables and functions in the decompressor 2010-08-02 15:34:44 -07:00