ksmbd: fix out-of-bounds read in expired-session LOCK check
Subsystems (3)
Michail Andreas Michalopoulos
Tested-byOn 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.
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 returnSTATUS_NETWORK_SESSION_EXPIREDand change nothing
- a compound of an unlock and a lock returnsSTATUS_SUCCESSandSTATUS_NETWORK_SESSION_EXPIRED
- READ is refused; CLOSE and LOGOFF succeedThese 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 unsignedSTATUS_ACCESS_DENIEDinstead of aSTATUS_NETWORK_SESSION_EXPIREDsigned 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!