KernelScan.io

CRITICAL

ksmbd TreeConnect UAF

CVE-2026-89788

CVSS 9.8 / 10.0 NVD

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.5HIGH

01

In the Linux kernel, the following vulnerability has been resolved: ksmbd: fix tree connection use-after-free in smb2_tree_connect() ksmbd_tree_conn_connect() publishes a new tree connection in sess->tree_conns with a single reference and returns its pointer to smb2_tree_connect(). The handler continues to initialize the object and build the response after publication. A concurrent session logoff can erase the connection and drop that reference, freeing the object while the handler still uses it. BUG: KASAN: slab-use-after-free in smb2_tree_connect+0xe3d/0xf90 smb2_tree_connect (fs/smb/server/smb2pdu.c:2872) handle_ksmbd_work process_one_work worker_thread kthread After xa_store() succeeds, take a second reference before releasing tree_conns_lock. The original reference belongs to the xarray entry and the second belongs to the creating smb2_tree_connect() handler. Keep the references balanced in every path: - On normal exit or an error after publication, smb2_tree_connect() drops its creator reference. Error cleanup also calls ksmbd_tree_conn_disconnect(), which drops the xarray reference only if it removes the exact entry. - SMB2 TREE_DISCONNECT uses the same helper to remove the entry and drop its xarray reference. The request's existing lookup reference remains owned by the request and is released by the existing cleanup. - Session LOGOFF removes each entry and drops its xarray reference. If it wins the race, later cleanup sees that the entry is gone and does not drop that reference again. To enforce this ownership, claim the disconnected state and erase the exact entry atomically under tree_conns_lock. This guarantees one drop for the xarray reference and one drop by each in-flight user, regardless of which teardown path wins. If logoff removes the entry before initialization completes, fail the connect instead of marking the detached object TREE_CONNECTED.

02

Engine v0.6.0

Risk summary

An authenticated remote SMB client can trigger a use-after-free in the ksmbd in-kernel SMB server by racing a tree-connect request against a session logoff. The freed tree-connection object is then accessed by the connect handler, leading to kernel memory corruption that can result in information disclosure, privilege escalation, or a kernel crash. Any deployment exposing ksmbd on TCP port 445 to untrusted or semi-trusted networks is at risk.

Affectedfs/smb/server/smb2pdu.c (ksmbd SMB server)

Vulnerability analysis

When an SMB client sends a tree-connect request, the server creates and publishes a connection object in a shared table, then continues working with that object. A concurrent session logoff can remove and free that object before the connect handler finishes using it. The fix adds an extra reference count for the handler so the object stays alive until initialization is complete, and makes the disconnect path verify the exact entry atomically so cleanup happens exactly once. Any authenticated SMB client on the network can reach this code; no special privileges beyond a valid session are needed.

03

BranchIntroducedFixed inPatch commit
5.155.15.1455.164e30fbd26e84
6.16.1.716.2b5ec6c462aab
7.2—7.2.6—
mainline—7.3-rc2—