CVE-2026-89635: ksmbd: only rebind the reopened file's own oplock on durable reconnect
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: only rebind the reopened file's own oplock on durable reconnect
ksmbdreopendurablefd() walks the inode's moplist and rebinds every detached oplock to the reconnecting session:
listforeachentryrcu(op, &ci->moplist, opentry, lockdepisheld(&ci->mlock)) { if (op->conn) continue; op->conn = ksmbdconnget(fp->conn); op->sess = work->sess; }
The only key is op->conn == NULL, which every detached durable handle on that inode matches, not just the one owned by fp. When two sessions hold durable handles on the same file and both disconnect, reconnecting one of them adopts the other session's oplock: op->sess is overwritten with the reconnecting session without taking a reference on it, while op->conn pins the connection.
The sibling teardown path, sessionfdcheck(), keys on the identity of the connection being torn down (op->conn == conn) rather than on shared state, and so does not have this problem.
Once the adopting session is destroyed, ksmbdsessiondestroy() frees it while the foreign oplock still points at it. The reader in ksmbdclosefdappinstanceid() validates only opinfo->conn, which is still live thanks to the reference taken above, and then dereferences the stale session:
if (!opinfo->conn) { upread(&fp->fci->mlock); goto out; }
ft = &opinfo->sess->filetable; writelock(&ft->lock);
BUG: KASAN: slab-use-after-free in rawwritelock+0x74/0xd0 Write of size 4 at addr ffff88810a970528 by task kworker/0:0/9 Workqueue: ksmbd-io handleksmbdwork Call Trace: rawwritelock+0x74/0xd0 ksmbdclosefdappinstanceid+0x183/0x410 smb2open+0x1346/0x4430 handleksmbdwork+0x2bb/0x7b0
Reached from an authenticated session against a share with the default durable-handle and oplock configuration: two sessions open the same file with a durable-v2 handle and an RH lease under distinct AppInstanceIds, both log off, one reconnects with DH2C, and a later durable-v2 create carrying the other AppInstanceId walks into the freed session.
Constrain the loop to the oplock owned by the file being reopened.
Affected Software
Event History
Frequently Asked Questions
What connection pattern is required for the described use-after-free condition?
The described condition involves two sessions holding durable handles for the same file, with both sessions disconnected. When one session reconnects, its reopen can adopt the other session’s detached oplock.
Why does reconnecting one session affect the other session's handle?
The reopen logic selects detached oplocks based only on a missing connection pointer, rather than verifying that the oplock belongs to the file being reopened. It can therefore assign the reconnecting session to a foreign oplock on the same inode.
What happens after the reconnecting session is torn down?
The foreign oplock can retain a pointer to the destroyed session. A later close path checks the oplock connection but not the validity of that session pointer, creating a use-after-free condition.