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>
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;
}