1
0
Fork 0
alistair23-linux/arch
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
..
alpha Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
arc Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
arm lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
arm64 Merge branch 'akpm' (patches from Andrew) 2015-09-08 17:52:23 -07:00
avr32 Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
blackfin Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
c6x Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-01 14:33:35 -07:00
cris cris/time: Migrate to new 'set-state' interface 2015-08-10 11:41:08 +02:00
frv Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
h8300 lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
hexagon atomic: Provide atomic_{or,xor,and} 2015-07-27 14:06:24 +02:00
ia64 kexec: split kexec_load syscall from kexec core code 2015-09-10 13:29:01 -07:00
m32r lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
m68k kexec: split kexec_load syscall from kexec core code 2015-09-10 13:29:01 -07:00
metag Mostly this is just clean ups and micro optimizations. 2015-09-08 14:04:14 -07:00
microblaze Mostly this is just clean ups and micro optimizations. 2015-09-08 14:04:14 -07:00
mips lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
mn10300 Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-03 15:46:07 -07:00
nios2 mm: clean up per architecture MM hook header files 2015-07-17 16:39:53 -07:00
openrisc openrisc/time: Migrate to new 'set-state' interface 2015-08-10 11:41:02 +02:00
parisc parisc: Use platform_device_register_simple("rtc-generic") 2015-09-08 17:53:48 +02:00
powerpc kexec: split kexec_load syscall from kexec core code 2015-09-10 13:29:01 -07:00
s390 lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
score Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-01 14:04:50 -07:00
sh lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
sparc Merge branch 'akpm' (patches from Andrew) 2015-09-08 17:52:23 -07:00
tile kexec: split kexec_load syscall from kexec core code 2015-09-10 13:29:01 -07:00
um Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-01 14:04:50 -07:00
unicore32 lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
x86 lib/decompressors: use real out buf size for gunzip with kernel 2015-09-10 13:29:01 -07:00
xtensa libnvdimm for 4.3: 2015-09-08 14:35:59 -07:00
.gitignore
Kconfig kexec: split kexec_load syscall from kexec core code 2015-09-10 13:29:01 -07:00