CVE-2026-99765: scsi: target: Fix demo-mode dynamic ACL dev-entry UAF vs LUN teardown
In the Linux kernel, the following vulnerability has been resolved:
scsi: target: Fix demo-mode dynamic ACL dev-entry UAF vs LUN teardown
A demo-mode (generatenodeacls=1) login that allocates a dynamic NodeACL populates that ACL's per-LUN dev entries in coretpgaddnodetodevs() before the ACL is linked onto tpg->aclnodelist by targetaddnodeacl():
coretpgcheckinitiatornodeacl(): ... coretpgaddnodetodevs(acl, tpg, NULL); / builds deves / targetaddnodeacl(acl); / only now listed /
The LUN teardown sweep, coreclearlunfromtpg(), enumerates only tpg->aclnodelist, so a dev entry whose ACL is still in the window above is invisible to the sweep and is never disabled. It is left on the selun->lundevelist after coretpgremovelun() frees the selun; when the same unpackedlun is later re-added and the selun is reallocated at the same address, the stale dev entry is rediscovered by targetnaclfinddeve() and coreenabledevicelistfornode() corrupts lundevelist:
BUG: KASAN: slab-use-after-free ... coreenabledevicelistfornode+0x5ce/0x880 coretpgaddnodetodevs+0x169/0x190 coredevaddlun+0x146/0x190 targetfabricportlink+0xe9/0x1b0 configfssymlink+0x381/0xae0 x64syssymlink+0x55/0x80
The demo-mode login path that drives the ACL/dev-entry creation is reachable by an unauthenticated initiator; the colliding LUN add/remove is a local configfs operation.
Commit 49cb77e297dc ("target: Avoid mappedlun symlink creation during lun shutdown") introduced selun->lunshutdown and guarded the explicit ACL MappedLUN path (targetfabricmappedlunlink()), but the demo-mode automatic path, coretpgaddnodetodevs() -> coreenabledevicelistfornode(), was never given the equivalent guard, and the publish-after-populate ordering in coretpgcheckinitiatornodeacl() was left unchanged.
Fix it in three cooperating parts:
1) Publish the dynamic NodeACL onto aclnodelist before creating its dev entries, so the teardown sweep can observe them.
2) Refuse to attach a dev entry to an selun that is shutting down, checked under nacl->lunentrymutex -- the same lock the sweep takes -- so once the sweep has passed an ACL any later enable for that LUN observes lunshutdown and skips it.
3) In coreenabledevicelistfornode(), insert the new dev entry onto lun->lundevelist while still holding nacl->lunentrymutex, in both the replace and the new-entry branch. Previously the entry was added to nacl->lunentryhlist under the mutex but to lun->lundevelist only after dropping it; with the ACL now published early, the sweep could take the mutex in that gap, find the entry on the hlist, coredisabledevicelistfornode() it (listdel() on the not-yet- linked lunlink succeeds and the entry is freed), and then the enable would listaddtail() the freed entry back onto lundevelist. Linking both lists under the mutex makes enable and the sweep mutually exclusive, closing that window.
coretpgaddnodetodevs() already ignores the return value of coreenabledevicelistfornode(), so a shutting-down LUN is simply skipped.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 3.11 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 3.19 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 4.2 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 4.5 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 4.10 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 4.11 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Compensating control
In the demo-mode dynamic ACL path, publish the NodeACL on tpg->acl_node_list before creating its per-LUN device entries. In core_enable_device_list_for_node(), check se_lun->lun_shutdown while holding nacl->lun_entry_mutex and skip entries for shutting-down LUNs; while holding that mutex, add new entries to lun->lun_deve_list in both the replace and new-entry branches so the LUN teardown sweep and enable operation are mutually exclusive.
Frequently Asked Questions
Which systems are exposed to this issue?
Systems using the Linux kernel SCSI target subsystem with demo-mode dynamic ACLs enabled (generate_node_acls=1) are exposed when a login creates a dynamic NodeACL while a LUN is being torn down or later re-added.
What conditions are needed to trigger the use-after-free?
A demo-mode login must allocate a dynamic NodeACL during the interval after its per-LUN device entries are created but before the ACL is linked into the target portal group's ACL list. A LUN teardown during that interval can leave a stale device entry, which may be reused when the same unpacked LUN is added again.
Are default configurations affected?
The described vulnerable path specifically requires demo mode with generate_node_acls=1. The provided information does not establish exposure for configurations where demo-mode dynamic ACL generation is not enabled.
What can be done if the fix cannot be applied immediately?
Avoid enabling or using demo-mode dynamic ACL generation (generate_node_acls=1) in affected SCSI target configurations. Also avoid the triggering combination of dynamic demo-mode logins and concurrent LUN teardown or re-add operations.