* [PATCH] ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount
@ 2026-04-18 15:45 Akif Sait
0 siblings, 0 replies; only message in thread
From: Akif Sait @ 2026-04-18 15:45 UTC (permalink / raw)
To: linkinjeon, smfrench; +Cc: senozhatsky, tom, linux-cifs, Akif Sait
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>
---
Hi Namjae, Steve,
smb2_lock processes LockCount lock elements using a nested loop where
each element checks all previous elements for conflicts. With no cap on
LockCount a single authenticated request with LockCount=65535 results in
roughly 2.1 billion iterations inside a ksmbd worker thread, pinning the
CPU completely. A few concurrent requests hang the host entirely.
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.
Let me know if you need more info or a reproducer.
Thanks,
Akif
fs/smb/server/smb2pdu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index ee32e61b6d3c..012f0c3585a0 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -7492,7 +7492,7 @@ int smb2_lock(struct ksmbd_work *work)
lock_ele = req->locks;
ksmbd_debug(SMB, "lock count is %d\n", lock_count);
- if (!lock_count) {
+ if (!lock_count || lock_count > 64) {
err = -EINVAL;
goto out2;
}
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-18 15:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-18 15:45 [PATCH] ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount Akif Sait
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox