android_kernel_lge_bullhead/arch/x86/boot
Yinghai Lu 6ccec4ea9c 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: 1431574a1c4 (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>
2019-08-26 17:03:29 +02:00
..
compressed lib/decompressors: use real out buf size for gunzip with kernel 2019-08-26 17:03:29 +02:00
tools x86/efi: Include a .bss section within the PE/COFF headers 2014-07-31 12:53:52 -07:00
.gitignore x86: remove offsets.h from .gitignore and dontdiff 2012-11-19 14:10:53 +01:00
Makefile x86, build: copy ldlinux.c32 to image.iso 2016-08-27 11:40:22 +02:00
a20.c x86, setup: "glove box" BIOS interrupts in the core boot code 2009-04-09 16:08:11 -07:00
apm.c x86, setup: "glove box" BIOS interrupts in the APM code 2009-04-09 16:08:11 -07:00
bioscall.S x86, boot: use .code16gcc instead of .code16 2009-06-16 17:47:32 -07:00
bitops.h x86: remove pointless comments 2008-04-19 19:19:54 +02:00
boot.h x86, boot: Pass cmd_line_ptr with unsigned long instead 2013-01-29 15:26:09 -08:00
cmdline.c x86, boot: Pass cmd_line_ptr with unsigned long instead 2013-01-29 15:26:09 -08:00
code16gcc.h
copy.S x86: copy.S - use GLOBAL,ENDPROC macros 2009-02-19 17:13:00 +01:00
cpu.c x86 setup: handle more than 8 CPU flag words 2008-09-16 15:09:26 -07:00
cpucheck.c x86: boot: stub out unimplemented CPU feature words 2008-09-05 16:13:44 -07:00
ctype.h x86, setup: move isdigit.h to ctype.h, header files on top. 2010-08-02 21:07:20 -07:00
early_serial_console.c x86, setup: Fix earlyprintk=serial,0x3f8,115200 2010-09-21 10:18:33 -07:00
edd.c x86, setup: "glove box" BIOS interrupts in the EDD code 2009-04-09 16:08:11 -07:00
header.S x86/efi: Include a .bss section within the PE/COFF headers 2014-07-31 12:53:52 -07:00
install.sh kbuild: use INSTALLKERNEL to select customized installkernel script 2009-09-20 12:18:14 +02:00
main.c keyboard: Use BIOS Keyboard variable to set Numlock 2012-05-08 14:19:41 -07:00
mca.c x86, setup: "glove box" BIOS interrupts in the MCA code 2009-04-09 16:08:11 -07:00
memory.c x86, setup: When probing memory with e801, use ax/bx as a pair 2011-04-25 14:52:37 -07:00
mkcpustr.c UAPI: Partition the header include path sets and add uapi/ header directories 2012-10-02 18:01:26 +01:00
mtools.conf.in
pm.c x86: remove zImage support 2009-03-11 11:00:00 -07:00
pmjump.S x86, setup: move 32-bit code to .text32 2009-03-17 15:26:06 -07:00
printf.c x86, setup: reorganize the early console setup 2010-08-02 15:51:56 -07:00
regs.c x86, setup: "glove box" BIOS calls -- infrastructure 2009-04-09 16:08:11 -07:00
setup.ld x86, boot: Define the 2.12 bzImage boot protocol 2013-01-27 15:56:37 -08:00
string.c x86, efi: EFI boot stub support 2011-12-12 14:26:10 -08:00
tty.c x86, setup: reorganize the early console setup 2010-08-02 15:51:56 -07:00
version.c kbuild: move utsrelease.h to include/generated 2009-12-12 13:08:15 +01:00
vesa.h x86-boot: don't request VBE2 information 2008-03-07 16:39:14 +01:00
video-bios.c x86: fix usage of bios intcall() 2009-07-04 12:56:32 -07:00
video-mode.c x86: move suspend wakeup code to C 2008-04-17 17:41:37 +02:00
video-vesa.c Merge branch 'x86-setup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-09-14 08:01:47 -07:00
video-vga.c x86, setup: Set ax register in boot vga query 2010-06-10 15:24:29 -07:00
video.c x86, setup: When restoring the screen, update boot_params.screen_info 2010-02-17 18:32:06 -08:00
video.h x86, setup: remove obsolete pre-Kconfig CONFIG_VIDEO_ variables 2009-06-26 11:02:31 -07:00