summaryrefslogtreecommitdiffstats
path: root/sys/boot/efi
diff options
context:
space:
mode:
authorallanjude <allanjude@FreeBSD.org>2016-05-01 21:06:59 +0000
committerallanjude <allanjude@FreeBSD.org>2016-05-01 21:06:59 +0000
commit3cff825845822e164de247eb0faa6c6500327675 (patch)
tree6d8e8798ae3ae0d9bc00e6d77f7642edc4991025 /sys/boot/efi
parenta1c17c1c6a2ab01784b049bd825561f7031c02d4 (diff)
downloadFreeBSD-src-3cff825845822e164de247eb0faa6c6500327675.zip
FreeBSD-src-3cff825845822e164de247eb0faa6c6500327675.tar.gz
bcache read ahead may attempt to read past end of disk
The new bcache code does not know the size of the disk, and therefore may attempt to read past the end of the disk while trying to fill its read-ahead cache. This is usually not an issue, it fails gracefully on all of my machines, but some BIOSes seem to retry the reads for up to 30 seconds each, resulting in a long stall during boot Submitted by: Toomas Soome <tsoome@me.com> Reviewed by: jhb, np Differential Revision: https://reviews.freebsd.org/D6109
Diffstat (limited to 'sys/boot/efi')
-rw-r--r--sys/boot/efi/libefi/efipart.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/boot/efi/libefi/efipart.c b/sys/boot/efi/libefi/efipart.c
index 2cf009a..da420bf 100644
--- a/sys/boot/efi/libefi/efipart.c
+++ b/sys/boot/efi/libefi/efipart.c
@@ -321,6 +321,15 @@ efipart_realstrategy(void *devdata, int rw, daddr_t blk, size_t offset,
if (size == 0 || (size % 512) != 0)
return (EIO);
+ off = blk * 512;
+ /* make sure we don't read past disk end */
+ if ((off + size) / blkio->Media->BlockSize - 1 >
+ blkio->Media->LastBlock) {
+ size = blkio->Media->LastBlock + 1 -
+ off / blkio->Media->BlockSize;
+ size = size * blkio->Media->BlockSize;
+ }
+
if (rsize != NULL)
*rsize = size;
@@ -335,7 +344,6 @@ efipart_realstrategy(void *devdata, int rw, daddr_t blk, size_t offset,
return (ENOMEM);
error = 0;
- off = blk * 512;
blk = off / blkio->Media->BlockSize;
blkoff = off % blkio->Media->BlockSize;
blksz = blkio->Media->BlockSize - blkoff;
OpenPOWER on IntegriCloud