<p dir="ltr">The code itself looks good but I'd like more details. Reading 0xffffffff shouldn't cause reboot. Why does it?</p>
<div class="gmail_quote">Le 1 nov. 2015 3:53 PM, "Andrei Borzenkov" <<a href="mailto:arvidjaar@gmail.com">arvidjaar@gmail.com</a>> a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I was debugging problem reported by user on Dell Dimension 8300 - it rebooted when doing "ls -l". It turned out, the problem was triggered by loading cbfs which probed for header. System has 2GB memory, and attempt to read from address 0xffffffff caused instant reboot. 0xffffffff was returned by read from non-existing address 0xfffffffc.<br>
<br>
The proof of concept patch below avoids it, but I wonder what the proper fix is.<br>
<br>
diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c<br>
index a34eb88..a5a2fde 100644<br>
--- a/grub-core/fs/cbfs.c<br>
+++ b/grub-core/fs/cbfs.c<br>
@@ -344,8 +344,9 @@ init_cbfsdisk (void)<br>
<br>
   ptr = *(grub_uint32_t *) 0xfffffffc;<br>
   head = (struct cbfs_header *) (grub_addr_t) ptr;<br>
+  grub_dprintf ("cbfs", "head=%p\n", head);<br>
<br>
-  if (!validate_head (head))<br>
+  if (0xffffffff - ptr < sizeof (*head) || !validate_head (head))<br>
     return;<br>
<br>
   cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize),<br>
<br>
<br>
_______________________________________________<br>
Grub-devel mailing list<br>
<a href="mailto:Grub-devel@gnu.org" target="_blank">Grub-devel@gnu.org</a><br>
<a href="https://lists.gnu.org/mailman/listinfo/grub-devel" rel="noreferrer" target="_blank">https://lists.gnu.org/mailman/listinfo/grub-devel</a><br>
</blockquote></div>