mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
e6023367d7
When choosing a random address, the current implementation does not take into
account the reversed space for .bss and .brk sections. Thus the relocated kernel
may overlap other components in memory. Here is an example of the overlap from a
x86_64 kernel in qemu (the ranges of physical addresses are presented):
Physical Address
0x0fe00000 --+--------------------+ <-- randomized base
/ | relocated kernel |
vmlinux.bin | (from vmlinux.bin) |
0x1336d000 (an ELF file) +--------------------+--
\ | | \
0x1376d870 --+--------------------+ |
| relocs table | |
0x13c1c2a8 +--------------------+ .bss and .brk
| | |
0x13ce6000 +--------------------+ |
| | /
0x13f77000 | initrd |--
| |
0x13fef374 +--------------------+
The initrd image will then be overwritten by the memset during early
initialization:
[ 1.655204] Unpacking initramfs...
[ 1.662831] Initramfs unpacking failed: junk in compressed archive
This patch prevents the above situation by requiring a larger space when looking
for a random kernel base, so that existing logic can effectively avoids the
overlap.
[kees: switched to perl to avoid hex translation pain in mawk vs gawk]
[kees: calculated overlap without relocs table]
Fixes:
|
||
---|---|---|
.. | ||
compressed | ||
tools | ||
.gitignore | ||
a20.c | ||
apm.c | ||
bioscall.S | ||
bitops.h | ||
boot.h | ||
cmdline.c | ||
code16gcc.h | ||
copy.S | ||
cpu.c | ||
cpucheck.c | ||
cpuflags.c | ||
cpuflags.h | ||
ctype.h | ||
early_serial_console.c | ||
edd.c | ||
header.S | ||
install.sh | ||
main.c | ||
Makefile | ||
mca.c | ||
memory.c | ||
mkcpustr.c | ||
mtools.conf.in | ||
pm.c | ||
pmjump.S | ||
printf.c | ||
regs.c | ||
setup.ld | ||
string.c | ||
string.h | ||
tty.c | ||
version.c | ||
vesa.h | ||
video-bios.c | ||
video-mode.c | ||
video-vesa.c | ||
video-vga.c | ||
video.c | ||
video.h |