Page MenuHomeFreeBSD

bhyve: Avoid unlikely truncation of the blockif ident strings.
ClosedPublic

Authored by jhb on Nov 23 2022, 11:16 PM.
Tags
None
Referenced Files
F82060984: D37488.id113535.diff
Thu, Apr 25, 3:46 AM
F82022819: D37488.id113590.diff
Wed, Apr 24, 4:48 PM
Unknown Object (File)
Sun, Apr 21, 12:20 AM
Unknown Object (File)
Wed, Apr 10, 3:56 AM
Unknown Object (File)
Sun, Mar 31, 8:52 AM
Unknown Object (File)
Thu, Mar 28, 6:52 PM
Unknown Object (File)
Thu, Mar 28, 10:18 AM
Unknown Object (File)
Feb 15 2024, 8:40 AM

Details

Summary

The ident string for NVMe and VirtIO block deivces do not contain the
bus, and the various fields can potentially use up to three characters
when printed as unsigned values (full range of uint8_t) even if not
likely in practice.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Nov 23 2022, 11:16 PM
This revision is now accepted and ready to land.Nov 24 2022, 6:35 AM

GCC still warns about a potential overflow after this, but I think GCC's overflow checking has an off by one error.

usr.sbin/bhyve/pci_nvme.c
3229

Have you tried using %u? Maybe gcc warns due to the possible minus sign of signed integers?

LGTM but I'm also curious if @corvink suggestion of %u helps

Yes, %u helps, and there's actually similar bugs in ahci and virtio_blk so I'll update the review to fix all of those.

jhb retitled this revision from bhyve: Avoid unlikely truncation of the blockif ident for NVMe. to bhyve: Avoid unlikely truncation of the blockif ident strings..Nov 27 2022, 12:19 AM
jhb edited the summary of this revision. (Show Details)

Use %u, add ahci and virtio-blk

This revision now requires review to proceed.Nov 27 2022, 12:20 AM
This revision is now accepted and ready to land.Nov 27 2022, 8:01 AM