CVE-2026-98870: ksmbd: remove stale channels from all sessions on teardown
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: remove stale channels from all sessions on teardown
ksmbdsessionsderegister() removes a connection's channels from other sessions' channel lists only while conn->binding is still set:
if (conn->binding) { hashforeachsafe(sessionstable, ...) ksmbdchanndel(conn, sess); }
conn->binding is a transient flag: it is cleared once a binding SESSIONSETUP completes, and also by a subsequent non-binding SESSIONSETUP on the same connection (a reauthentication on a bound channel, or a new SessionId==0 setup). A connection that has bound a channel into another session's ksmbdchannlist and then clears conn->binding leaves that channel behind when it disconnects: the channel, whose chann->conn points at the now freed struct ksmbdconn, stays on the owner session's list.
When the owning connection later tears down, the second loop dereferences the stale channel:
xaforeach(&sess->ksmbdchannlist, channid, chann) if (chann->conn != conn) ksmbdconnsetexiting(chann->conn); / freed /
which is a use-after-free write into the freed ksmbdconn (the same stale channel is also walked by showprocsession() through /proc). The session is leaked as well, because its channel list never empties.
Remove the conn->binding gate so a connection always removes its channels from every session on teardown.