ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount

smb2_lock() performs O(N^2) conflict detection with no cap on LockCount.
Cap lock_count at 64 to prevent CPU exhaustion from a single request.

Signed-off-by: Akif Sait <akif.sait111@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Akif Sait 2026-04-20 10:58:26 +09:00 committed by Steve French
parent b32c8db482
commit bd0a1ca52b

View File

@ -7491,7 +7491,12 @@ int smb2_lock(struct ksmbd_work *work)
lock_ele = req->locks;
ksmbd_debug(SMB, "lock count is %d\n", lock_count);
if (!lock_count) {
/*
* Cap lock_count at 64. The MS-SMB2 spec defines Open.LockSequenceArray
* as exactly 64 entries so 64 is the intended ceiling. No real workload
* comes close to this in a single request.
*/
if (!lock_count || lock_count > 64) {
err = -EINVAL;
goto out2;
}