grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What is this grub_disk_read doing in the i386 linux loader


From: Andrew Jeddeloh
Subject: What is this grub_disk_read doing in the i386 linux loader
Date: Thu, 19 Apr 2018 20:12:45 -0700

While solving a bug in the coreos fork of grub I came across this disk
read in the i386 linux loader [1]. It looks like its reading whatever
is after the boot param header in the kernel file (defined by the
linux x86 boot protocol [2]) into the rest of the `linux_params`
struct. In practice this means overwriting part of the padding and the
e820 map. As far as I can tell, this is not necessary or a useful
thing to do. Am I missing something?

The bug we were hitting on our fork was miscalculating
(char*)&linux_params + sizeoh(lh) as &linux_params + sizeof(lh), which
(in addition to corrupting memory) means the contents wasn't being
written to (char*)&linux_params + sizeof(lh). However the machines
seem to boot just fine when the memory corruption didn't cause
problems. If I nop out the call to read that chunk into
(char*)linux_params + sizeof(lh) it also seems to boot fine.

Is this intended? If so what is it doing? It dates back to the
original i386 linux loader support [3], but I can't figure out why
this would be intended.

Thanks,
- Andrew

[1] 
http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/loader/i386/linux.c#n809
[2] https://www.kernel.org/doc/Documentation/x86/boot.txt
[3] 
http://git.savannah.gnu.org/cgit/grub.git/commit/grub-core/loader/i386/linux.c?id=8c411768822a75c8c15108872191a05e84befa6e



reply via email to

[Prev in Thread] Current Thread [Next in Thread]