]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyve nvme: Fix LBA out-of-range calculation
authorChuck Tuffli <chuck@FreeBSD.org>
Sun, 30 Jan 2022 07:09:57 +0000 (23:09 -0800)
committerChuck Tuffli <chuck@FreeBSD.org>
Sun, 30 Jan 2022 07:09:57 +0000 (23:09 -0800)
commit9d8cd04694d47d48cc4003f8322739ba10fa8108
tree016b74b1619e838a82e9d9af70d271f8a32c7a29
parent073f2076fea4748b457b15dbd1d6e11b802b76f3
bhyve nvme: Fix LBA out-of-range calculation

The function which checks for a valid LBA range mistakenly named an
input value as NLB ("Number of Logical Blocks") instead of "number of
blocks". The NVMe specification defines NLB as a zero-based value (i.e.
NLB=0x0 represents 1 block, 0x1 is 2 blocks, etc.), but the passed
parameter is a 1's-based value.

Fix is to rename the variable to avoid future confusion.

While in the neighborhood, also check that the starting LBA is less than
the size of the backing storage to avoid an integer overflow.

Reviewed by: imp, allanjude, jhb
Tested by:      jason@tubnor.net
MFC after:      1 month
Differential Revision: https://reviews.freebsd.org/D33575
usr.sbin/bhyve/pci_nvme.c