public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
From: Akif Sait <akif.sait111@gmail.com>
To: linkinjeon@kernel.org, smfrench@gmail.com
Cc: senozhatsky@chromium.org, tom@talpey.com,
	linux-cifs@vger.kernel.org, Akif Sait <akif.sait111@gmail.com>
Subject: [PATCH] ksmbd: fix O(N^2) DoS in smb2_lock via unbounded LockCount
Date: Sat, 18 Apr 2026 21:15:05 +0530	[thread overview]
Message-ID: <20260418154505.84684-1-akif.sait111@gmail.com> (raw)

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


                 reply	other threads:[~2026-04-18 15:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260418154505.84684-1-akif.sait111@gmail.com \
    --to=akif.sait111@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=smfrench@gmail.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox