]> xenbits.xensource.com Git - people/liuw/stubdom.git/commitdiff
PV-GRUB: fix blk access at end of disk
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Fri, 21 Mar 2014 01:56:56 +0000 (02:56 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 21 Mar 2014 11:49:24 +0000 (11:49 +0000)
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.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
grub/mini-os.c

index 8cecf9013fad4a565f56169b9d3c66cae16d3a6f..64ab962feef51d2f028f8a4d74cafdced2fc9ddf 100644 (file)
@@ -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;