Skip to content

Commit bd0a1ca

Browse files
Akif-Saitsmfrench
authored andcommitted
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 <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b32c8db commit bd0a1ca

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/smb/server/smb2pdu.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7491,7 +7491,12 @@ int smb2_lock(struct ksmbd_work *work)
74917491
lock_ele = req->locks;
74927492

74937493
ksmbd_debug(SMB, "lock count is %d\n", lock_count);
7494-
if (!lock_count) {
7494+
/*
7495+
* Cap lock_count at 64. The MS-SMB2 spec defines Open.LockSequenceArray
7496+
* as exactly 64 entries so 64 is the intended ceiling. No real workload
7497+
* comes close to this in a single request.
7498+
*/
7499+
if (!lock_count || lock_count > 64) {
74957500
err = -EINVAL;
74967501
goto out2;
74977502
}

0 commit comments

Comments
 (0)