b53a2f2c66
Recent work around x86 Linux kernel loader revealed an underflow in the
setup_header length calculation and another related issue. Both lead to
the memory overwrite and later machine crash.
Currently when the GRUB copies the setup_header into the linux_params
(struct boot_params, traditionally known as "zero page") it assumes the
setup_header size as sizeof(linux_i386_kernel_header/lh). This is
incorrect. It should use the value calculated accordingly to the Linux
kernel boot protocol. Otherwise in case of pretty old kernel, to be
exact Linux kernel boot protocol, the GRUB may write more into
linux_params than it was expected to. Fortunately this is not very big
issue. Though it has to be fixed. However, there is also an underflow
which is grave. It happens when
sizeof(linux_i386_kernel_header/lh) > "real size of the setup_header".
Then len value wraps around and grub_file_read() reads whole kernel into
the linux_params overwriting memory past it. This leads to the GRUB
memory allocator breakage and finally to its crash during boot.
The patch fixes both issues. Additionally, it moves the code not related to
grub_memset(linux_params)/grub_memcpy(linux_params)/grub_file_read(linux_params)
section outside of it to not confuse the reader.
Fixes:
|
||
---|---|---|
.. | ||
boot | ||
bus | ||
commands | ||
disk | ||
efiemu | ||
font | ||
fs | ||
gdb | ||
gettext | ||
gfxmenu | ||
hello | ||
hook | ||
io | ||
kern | ||
lib | ||
loader | ||
mmap | ||
net | ||
normal | ||
osdep | ||
partmap | ||
parttool | ||
script | ||
term | ||
tests | ||
video | ||
gdb_grub.in | ||
genemuinit.sh | ||
genemuinitheader.sh | ||
genmod.sh.in | ||
genmoddep.awk | ||
gensyminfo.sh.in | ||
gensymlist.sh | ||
gentrigtables.c | ||
gmodule.pl.in | ||
Makefile.am | ||
Makefile.core.def | ||
modinfo.sh.in |