From: Namjae Jeon <linkinjeon@kernel.org>
To: DaeMyung Kang <charsyam@gmail.com>
Cc: Steve French <smfrench@gmail.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Tom Talpey <tom@talpey.com>,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] smb: server: fix max_connections off-by-one in tcp accept path
Date: Fri, 17 Apr 2026 08:36:44 +0900 [thread overview]
Message-ID: <CAKYAXd-P=E+bc+3W4DffU4SRtBDysJ+0yhmsxX7LvNB_8vR=sQ@mail.gmail.com> (raw)
In-Reply-To: <20260416211735.3558718-1-charsyam@gmail.com>
On Fri, Apr 17, 2026 at 6:17 AM DaeMyung Kang <charsyam@gmail.com> wrote:
>
> The global max_connections check in ksmbd's TCP accept path counts
> the newly accepted connection with atomic_inc_return(), but then
> rejects the connection when the result is greater than or equal to
> server_conf.max_connections.
>
> That makes the effective limit one smaller than configured. For
> example:
>
> - max_connections=1 rejects the first connection
> - max_connections=2 allows only one connection
>
> The per-IP limit in the same function uses <= correctly because it
> counts only pre-existing connections. The global limit instead checks
> the post-increment total, so it should reject only when that total
> exceeds the configured maximum.
>
> Fix this by changing the comparison from >= to >, so exactly
> max_connections simultaneous connections are allowed and the next one
> is rejected. This matches the documented meaning of max_connections
> in fs/smb/server/ksmbd_netlink.h as the "Number of maximum simultaneous
> connections".
>
> Fixes: 0d0d4680db22 ("ksmbd: add max connections parameter")
> Cc: stable@vger.kernel.org
> Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Applied it to #ksmbd-for-next-next.
Thanks!
prev parent reply other threads:[~2026-04-16 23:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 21:17 [PATCH] smb: server: fix max_connections off-by-one in tcp accept path DaeMyung Kang
2026-04-16 23:36 ` Namjae Jeon [this message]
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='CAKYAXd-P=E+bc+3W4DffU4SRtBDysJ+0yhmsxX7LvNB_8vR=sQ@mail.gmail.com' \
--to=linkinjeon@kernel.org \
--cc=charsyam@gmail.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=stable@vger.kernel.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).