Files
vuln-cve/data/2025/38xxx/CVE-2025-38658.json
T

138 lines
9.6 KiB
JSON

{
"dataType": "CVE_RECORD",
"dataVersion": "5.2",
"cveMetadata": {
"cveId": "CVE-2025-38658",
"assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"state": "PUBLISHED",
"assignerShortName": "Linux",
"dateReserved": "2025-04-16T04:51:24.031Z",
"datePublished": "2025-08-22T16:01:01.651Z",
"dateUpdated": "2026-08-05T12:03:45.053Z"
},
"containers": {
"cna": {
"providerMetadata": {
"orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"shortName": "Linux",
"dateUpdated": "2026-08-05T12:03:45.053Z"
},
"descriptions": [
{
"lang": "en",
"value": "In the Linux kernel, the following vulnerability has been resolved:\n\nnvmet: pci-epf: Do not complete commands twice if nvmet_req_init() fails\n\nHave nvmet_req_init() and req->execute() complete failed commands.\n\nDescription of the problem:\nnvmet_req_init() calls __nvmet_req_complete() internally upon failure,\ne.g., unsupported opcode, which calls the \"queue_response\" callback,\nthis results in nvmet_pci_epf_queue_response() being called, which will\ncall nvmet_pci_epf_complete_iod() if data_len is 0 or if dma_dir is\ndifferent from DMA_TO_DEVICE. This results in a double completion as\nnvmet_pci_epf_exec_iod_work() also calls nvmet_pci_epf_complete_iod()\nwhen nvmet_req_init() fails.\n\nSteps to reproduce:\nOn the host send a command with an unsupported opcode with nvme-cli,\nFor example the admin command \"security receive\"\n$ sudo nvme security-recv /dev/nvme0n1 -n1 -x4096\n\nThis triggers a double completion as nvmet_req_init() fails and\nnvmet_pci_epf_queue_response() is called, here iod->dma_dir is still\nin the default state of \"DMA_NONE\" as set by default in\nnvmet_pci_epf_alloc_iod(), so nvmet_pci_epf_complete_iod() is called.\nBecause nvmet_req_init() failed nvmet_pci_epf_complete_iod() is also\ncalled in nvmet_pci_epf_exec_iod_work() leading to a double completion.\nThis not only sends two completions to the host but also corrupts the\nstate of the PCI NVMe target leading to kernel oops.\n\nThis patch lets nvmet_req_init() and req->execute() complete all failed\ncommands, and removes the double completion case in\nnvmet_pci_epf_exec_iod_work() therefore fixing the edge cases where\ndouble completions occurred."
}
],
"metrics": [
{
"cvssV3_1": {
"version": "3.1",
"vectorString": "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"baseScore": 8.8,
"baseSeverity": "HIGH"
},
"scenarios": [
{
"lang": "en",
"value": "AV:A - The vulnerable code is the NVMe PCI *endpoint* target, driven entirely by NVMe commands submitted by a separate root-complex host across the PCIe link, so the attacker is external software on a directly-attached peer machine rather than a user of the endpoint system. In the deployments this driver targets (disaggregated/composable PCIe storage, and endpoint devices VFIO-passed-through to untrusted guests) no physical manipulation is needed at attack time — only presence on the same logically adjacent PCIe fabric.\nAC:L - A single NVMe command with an opcode the target does not implement deterministically fails nvmet_req_init() and produces the double completion; the commit itself gives a one-line nvme-cli reproducer. No timing, memory-layout, or victim-state condition outside the attacker's control is involved.\nPR:N - NVMe over PCIe has no authentication or authorization step — the host merely enables CC.EN, creates queues, and writes a doorbell — so the attacker holds no credentials at all on the vulnerable endpoint system. Any command submitter on the attached host or a passed-through guest reaches the failing path.\nUI:N - The endpoint's SQ-polling work item picks up the malformed command and dispatches it automatically. No action by any user or administrator on the victim endpoint system is required.\nS:U - The corruption is confined to the endpoint kernel's own heap and driver state, the same security authority that contains the vulnerable code. The cross-machine nature of the attack is already captured by the Attack Vector metric.\nC:H - The dangling CQ list entry causes nvmet_pci_epf_cq_work() to re-read a freed iod and build a completion entry from it (including a dereference of a possibly reallocated iod->sq), which is memcpy_toio()'d straight into the attacker host's completion queue, leaking reused kernel heap contents. More broadly, the double free and iod aliasing yield general heap-corruption primitives leverageable for arbitrary kernel memory disclosure.\nI:H - The same iod is returned to the mempool twice, so two concurrent commands are handed the identical object and its data_segs buffers are kfree()'d twice in shared kmalloc caches, with the attacker controlling those buffers' sizes and contents via PRP/SGL lists and DMA. A double free plus use-after-free write on an aliased object is a well-established path to controlled kernel writes and control-flow hijack.\nA:H - The commit explicitly states the double completion \"corrupts the state of the PCI NVMe target leading to kernel oops,\" and CONFIG_DEBUG_LIST additionally trips on the duplicate list_add. The attacker can repeat the triggering command at will to panic or wedge the endpoint system."
}
]
}
],
"affected": [
{
"product": "Linux",
"vendor": "Linux",
"defaultStatus": "unaffected",
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"programFiles": [
"drivers/nvme/target/pci-epf.c"
],
"versions": [
{
"version": "0faa0fe6f90ea59b10d1b0f15ce0eb0c18eff186",
"lessThan": "a535c0b10060bc8c174a7964b0f98064ee0c4774",
"status": "affected",
"versionType": "git"
},
{
"version": "0faa0fe6f90ea59b10d1b0f15ce0eb0c18eff186",
"lessThan": "746d0ac5a07d5da952ef258dd4d75f0b26c96476",
"status": "affected",
"versionType": "git"
}
]
},
{
"product": "Linux",
"vendor": "Linux",
"defaultStatus": "affected",
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"programFiles": [
"drivers/nvme/target/pci-epf.c"
],
"versions": [
{
"version": "6.14",
"status": "affected"
},
{
"version": "0",
"lessThan": "6.14",
"status": "unaffected",
"versionType": "semver"
},
{
"version": "6.16.1",
"lessThanOrEqual": "6.16.*",
"status": "unaffected",
"versionType": "semver"
},
{
"version": "6.17",
"lessThanOrEqual": "*",
"status": "unaffected",
"versionType": "original_commit_for_fix"
}
]
}
],
"cpeApplicability": [
{
"nodes": [
{
"operator": "OR",
"negate": false,
"cpeMatch": [
{
"vulnerable": true,
"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
"versionStartIncluding": "6.14",
"versionEndExcluding": "6.16.1"
},
{
"vulnerable": true,
"criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
"versionStartIncluding": "6.14",
"versionEndExcluding": "6.17"
}
]
}
]
}
],
"references": [
{
"url": "https://git.kernel.org/stable/c/a535c0b10060bc8c174a7964b0f98064ee0c4774"
},
{
"url": "https://git.kernel.org/stable/c/746d0ac5a07d5da952ef258dd4d75f0b26c96476"
}
],
"title": "nvmet: pci-epf: Do not complete commands twice if nvmet_req_init() fails",
"x_generator": {
"engine": "bippy-1.2.0"
}
}
}
}