Skip to contentSkip to conversation

ksmbd: fix out-of-bounds read in expired-session LOCK check

PATCH Applied Michail Andreas Michalopoulos 2 participants 2 messages Nov 12

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

On top of linux-next 20261105 with the four newer ksmbd-for-next commits up to a4277e7b7682, under KASAN, with session expiry forced by a test-only hook as in your notes. With well-formed requests on an expired session, before and after the patch:

- an unlock succeeds and releases the range; another client can then lock it
- a new lock, and a request that unlocks one range and locks another, both return STATUS_NETWORK_SESSION_EXPIRED and change nothing
- a compound of an unlock and a lock returns STATUS_SUCCESS and STATUS_NETWORK_SESSION_EXPIRED
- READ is refused; CLOSE and LOGOFF succeed

These results are the same with and without the patch, with no KASAN reports.
I did not test the malformed request itself.

One difference, for the better: a LOCK with a bad signature on an expired session now goes through the signature check in __process_request(), so it gets an unsigned STATUS_ACCESS_DENIED instead of a STATUS_NETWORK_SESSION_EXPIRED signed with the session's key. Patch 5/8 of my v5 signing series fixes the same thing for the other commands; the two patches do not overlap.

maintainer Applied
#1 lore raw
Quoted 18 lines · Michail Andreas Michalopoulos

On top of linux-next 20261105 with the four newer ksmbd-for-next commits up to a4277e7b7682, under KASAN, with session expiry forced by a test-only hook as in your notes. With well-formed requests on an expired session, before and after the patch:

- an unlock succeeds and releases the range; another client can then lock it
- a new lock, and a request that unlocks one range and locks another, both return STATUS_NETWORK_SESSION_EXPIRED and change nothing
- a compound of an unlock and a lock returns STATUS_SUCCESS and STATUS_NETWORK_SESSION_EXPIRED
- READ is refused; CLOSE and LOGOFF succeed

These results are the same with and without the patch, with no KASAN reports.
I did not test the malformed request itself.

Quoted 8 lines

One difference, for the better: a LOCK with a bad signature on an expired session now goes through the signature check in __process_request(), so it gets an unsigned STATUS_ACCESS_DENIED instead of a STATUS_NETWORK_SESSION_EXPIRED signed with the session's key. Patch 5/8 of my v5 signing series fixes the same thing for the other commands; the two patches do not overlap.

Applied it to #ksmbd-for-next.
Thanks!