Skip to contentSkip to conversation

PV-GRUB: fix blk access at end of disk

PATCH In review Samuel Thibault 3 participants 6 messages Mar 21, 2014 – Apr 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PV-GRUB: fix blk access at end of disk

GRUB usually always loads a whole disk track, even if that means going beyond the end of the disk. We thus have to gracefully return an error, instead of letting the blkfront go panic.

stubdom/grub/mini-os.c +3 -0
index 8cecf90..64ab962 100644
@@ -126,6 +126,9 @@ biosdisk (int read, int drive, struct geometry *geometry,
     if (i >= blk_nb)
         return -1;
 
+    if (sector + nsec > geometry->total_sectors)
+      return -1;
+
     aiocb.aio_dev = blk_dev[i];
     aiocb.aio_buf = addr;
     aiocb.aio_nbytes = (size_t)nsec * blk_info[i].sector_size;
#1 lore raw
Quoted 3 lines · Samuel Thibault, le Fri 21 Mar 2014 02:56:56 +0100, a écrit :

GRUB usually always loads a whole disk track, even if that means going beyond the end of the disk. We thus have to gracefully return an error, instead of letting the blkfront go panic.

(yes I was (un)lucky enough to see a generated initrd ending up at the very end of my /...)

This fix is very worth backporting to all stable trees.

Samuel

#2 lore raw
Quoted 7 lines · Samuel Thibault
Quoted 3 lines · Samuel Thibault, le Fri 21 Mar 2014 02:56:56 +0100, a écrit :

GRUB usually always loads a whole disk track, even if that means going beyond the end of the disk. We thus have to gracefully return an error, instead of letting the blkfront go panic.

(yes I was (un)lucky enough to see a generated initrd ending up at the very end of my /...)

Urk! Acked + applied.

(but should blkfront not also catch this and return an error?)

Quoted 1 line

This fix is very worth backporting to all stable trees.

CCing Ian J and Jan, not sure who deals with stubdom backports...

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 6 lines · Ian Campbell, le Fri 21 Mar 2014 12:20:04 +0000, a écrit :
Quoted 5 lines · Samuel Thibault
Quoted 3 lines · Samuel Thibault, le Fri 21 Mar 2014 02:56:56 +0100, a écrit :

GRUB usually always loads a whole disk track, even if that means going beyond the end of the disk. We thus have to gracefully return an error, instead of letting the blkfront go panic.

Quoted 6 lines
Quoted 2 lines

(yes I was (un)lucky enough to see a generated initrd ending up at the very end of my /...)

Urk! Acked + applied.

(but should blkfront not also catch this and return an error?)

Yes, and not only that, but also propagate errors coming from the blkback. I have added that to my TODO list.

Samuel

#4 lore raw
In reply to Ian Campbell

Ian Campbell writes ("Re: [Xen-devel] [PATCH] PV-GRUB: fix blk access at end of disk"):

Quoted 4 lines · Samuel Thibault
Quoted 1 line

This fix is very worth backporting to all stable trees.

CCing Ian J and Jan, not sure who deals with stubdom backports...

Me, probably. I have added it to my list.

Thanks,
Ian.

#5 lore raw

Ian Jackson writes ("Re: [Xen-devel] [PATCH] PV-GRUB: fix blk access at end of disk"):

Quoted 7 lines

Ian Campbell writes ("Re: [Xen-devel] [PATCH] PV-GRUB: fix blk access at end of disk"):

Quoted 4 lines · Samuel Thibault
Quoted 1 line

This fix is very worth backporting to all stable trees.

CCing Ian J and Jan, not sure who deals with stubdom backports...

Me, probably. I have added it to my list.

I have now backported this to 4.4, 4.3 and 4.2. It applied cleanly and I did a build test.

Thanks,
Ian.