aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2022-09-08 00:35:06 +0000
committerKyle Evans <kevans@FreeBSD.org>2022-09-18 06:26:40 +0000
commit7e04dc0797f3265a10975cac2670f0407487a925 (patch)
treead202dba559fe1dde56bad62146ddafb045bc64f
parent9a45e76cfd25c3a01ef44350ddbda603bb07e408 (diff)
downloadsrc-7e04dc0797f3265a10975cac2670f0407487a925.tar.gz
src-7e04dc0797f3265a10975cac2670f0407487a925.zip
stand: i386: take into account disk sector size for blk calculation
disk_blocks assumes BIOSDISK_SECSIZE, but the media may not be using it. In particular, bioscd on Parallels presents a 2K sector size, so we end up with a short disk_blocks and subsequent validation fails when trying to read /boot/lua. PR: 233098 Reviewed by: imp, tsoome (cherry picked from commit 72291cee075d9ef1a608b2a67762b44e024cc0d4)
-rw-r--r--stand/i386/libi386/biosdisk.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c
index 2c52617f255d..f8c712b324c6 100644
--- a/stand/i386/libi386/biosdisk.c
+++ b/stand/i386/libi386/biosdisk.c
@@ -1031,7 +1031,8 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t size,
d_offset = dev->d_offset;
}
if (disk_blocks == 0)
- disk_blocks = bd->bd_sectors - d_offset;
+ disk_blocks = bd->bd_sectors * (bd->bd_sectorsize /
+ BIOSDISK_SECSIZE) - d_offset;
/* Validate source block address. */
if (dblk < d_offset || dblk >= d_offset + disk_blocks)