]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bhyve nvme: Check return value of mapped memory
authorChuck Tuffli <chuck@FreeBSD.org>
Sun, 14 Aug 2022 14:45:21 +0000 (07:45 -0700)
committerChuck Tuffli <chuck@FreeBSD.org>
Sun, 14 Aug 2022 14:45:21 +0000 (07:45 -0700)
commit3d3678627c3112c94d174a8c51d8c058d02befb3
tree8e2fab0d49b977f9a05cac1c747dfb224653828c
parent8b55a4718c044e1f4cee3e00e16a7ab63550f53a
bhyve nvme: Check return value of mapped memory

Fuzzing of bhyve using hyfuzz discovered a way to cause a segmentation
fault in the NVMe emulation. If a guest specifies a physical address in
either the PRP1 or PRP2 field of a command that cannot be mapped from
guest to host, the function paddr_guest2host() returns a NULL pointer.
The NVMe emulation did not check for this error case, which allowed for
the segmentation fault to occur.

Fix is to check for a return value of NULL and indicate an error back to
the guest (Data Transfer error). While in the area, slightly refactor
the write/read blockif function to use a common error exit path.

PR: 256321
Reported by: Cheolwoo Myung <cwmyung@snu.ac.kr>
Reviewed by: imp, jhb
Differential Revision: https://reviews.freebsd.org/D35452
usr.sbin/bhyve/pci_nvme.c