Bhyve's nvme_opc_dataset_mgmt() can free(range) before initializing it: struct nvme_dsm_range *range; ...; if ((sc->ctrldata.oncs & NVME_ONCS_DSM) == 0) { pci_nvme_status_genc(status, NVME_SC_INVALID_OPCODE); goto out; } ...; range = calloc(1, NVME_MAX_DSM_TRIM); ...; out: free(range); A guest can cause this to happen by ringing the doorbell of a submission queue with an entry with cmd->opc NVME_OPC_DATASET_MANAGEMENT.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=7376c08cc67e65ee660d51873129e34745ef5dd4 commit 7376c08cc67e65ee660d51873129e34745ef5dd4 Author: Chuck Tuffli <chuck@FreeBSD.org> AuthorDate: 2022-06-09 20:05:46 +0000 Commit: Chuck Tuffli <chuck@FreeBSD.org> CommitDate: 2022-08-14 14:53:22 +0000 bhyve nvme: Fix uninitialized pointer The Dataset Management code could free an uninitialized pointer if the device doesn't support the Dataset Management command. PR: 264548 Reported by: Robert Morris <rtm@lcs.mit.edu> usr.sbin/bhyve/pci_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c84ec3076e7de10d7475fd9694ad64603e264d88 commit c84ec3076e7de10d7475fd9694ad64603e264d88 Author: Chuck Tuffli <chuck@FreeBSD.org> AuthorDate: 2022-06-09 20:05:46 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-01-20 21:07:27 +0000 bhyve nvme: Fix uninitialized pointer The Dataset Management code could free an uninitialized pointer if the device doesn't support the Dataset Management command. PR: 264548 Reported by: Robert Morris <rtm@lcs.mit.edu> (cherry picked from commit 7376c08cc67e65ee660d51873129e34745ef5dd4) usr.sbin/bhyve/pci_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d4e643f6a51d7fb8d8523419196449faa5fa047d commit d4e643f6a51d7fb8d8523419196449faa5fa047d Author: Chuck Tuffli <chuck@FreeBSD.org> AuthorDate: 2022-06-09 20:05:46 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-01-20 21:08:28 +0000 bhyve nvme: Fix uninitialized pointer The Dataset Management code could free an uninitialized pointer if the device doesn't support the Dataset Management command. PR: 264548 Reported by: Robert Morris <rtm@lcs.mit.edu> (cherry picked from commit 7376c08cc67e65ee660d51873129e34745ef5dd4) (cherry picked from commit c84ec3076e7de10d7475fd9694ad64603e264d88) usr.sbin/bhyve/pci_nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)