Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Sep 2022 06:27:18 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8a832ed2f8c1 - stable/12 - stand: i386: take into account disk sector size for blk calculation
Message-ID:  <202209180627.28I6RIk3068298@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=8a832ed2f8c1f87f6461d7a6932cec357b04e538

commit 8a832ed2f8c1f87f6461d7a6932cec357b04e538
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-09-08 00:35:06 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-09-17 19:32:52 +0000

    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)
---
 stand/i386/libi386/biosdisk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c
index 00d2de5de418..15e71348bb87 100644
--- a/stand/i386/libi386/biosdisk.c
+++ b/stand/i386/libi386/biosdisk.c
@@ -1025,7 +1025,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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202209180627.28I6RIk3068298>