bug-grub
[Top][All Lists]
Advanced

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

Re: Grub2 with VirtualBox Physical Partitions


From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: Grub2 with VirtualBox Physical Partitions
Date: Sun, 20 Jan 2013 23:16:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11

On 10.10.2012 01:22, Tyler Hardin wrote:

> Hi,
> 
> There seems to be a bug (or at least a bad idea) in the design on Grub2.
> When using it with VirtualBox's physical partition feature, a feature
> which allows a user to boot a physical partition in a virtual machine,
> it fails to load. More specifically, it freezes. This is likely due to
> VBox limiting the virtual machines disk access the specified partitions
> and the first 63 sectors of the disk. It seems that Grub2 is depending
> on data stored past those first 63 sectors and not in the partition it
> is installed on, which causes it to freeze when it tries to load its
> later stages from the disk. (FWIW, VBox returns zeros for reads to parts
> of the disk which are not allowed.)
> 
> So, my question is: where is Grub2's later stages actually installed and
> how hard would it be to install them in the first 63 sectors (32KiB)? Is
> it too big to fit there?

GRUB uses the space available before the first partition to store its core and 
Reed-Solomon redundancy. Later is needed because some malware rewrites our 
sectors and we want to be able to survive those. The problem is that if you 
change too many of recovery sectors this restore fails. Possibilities would be 
to install w/o Reed-Solomon with patch like this:
=== modified file 'util/grub-setup.c'
--- util/grub-setup.c   2013-01-20 15:52:15 +0000
+++ util/grub-setup.c   2013-01-20 22:11:28 +0000
@@ -509,6 +509,7 @@
       }
 
     assert (nsec <= maxsec);
+    nsec = core_sectors;
 
     /* Clean out the blocklists.  */
     block = first_block;

Or to add some detection of zeroed-out redundancy but then the size of recoverer
is very constrained. The patch would be:
=== modified file 'grub-core/lib/reed_solomon.c'
--- grub-core/lib/reed_solomon.c        2012-01-24 13:49:31 +0000
+++ grub-core/lib/reed_solomon.c        2013-01-20 22:14:46 +0000
@@ -382,11 +382,18 @@
 {
   gf_single_t *ptr = ptr_;
   gf_single_t *rptr = ptr + s;
+  grub_uint8_t *cptr;
 
   /* Nothing to do.  */
   if (!rs)
     return;
 
+  for (cptr = ptr_ + rs; cptr >= ptr_ + s; cptr--)
+    if (*cptr)
+      break;
+  if (ptr_ + rs - cptr > rs / 2)
+    return;
+
   init_powx ();
 
   while (s > 0)


But it needs furth checks as to its corectness and the size increase it creates.

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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