From nobody Tue Jun 16 05:57:33 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69AB3373C17 for ; Thu, 16 Apr 2026 21:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776374265; cv=none; b=fzUNb2zjr1UpPnko6Qyg897Vg5EiNlq8CoPg/i0atccOHnciExmbWeBDD0cEFPn0dSf3sJNxjKasGxBqGxOXXgg9tbbRL1nyNZQQalL4395YUA9EXYKA2TJsEBZuztFK5bC8jovM4bOIKzxirezfs/UYxeNpIFKwD41Sos++nAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776374265; c=relaxed/simple; bh=ygvlKmBj9cpYvhipO2GVwDfNG6msc7IzLgEFKCeFaeI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PfiQTW1pvOn2V2bt7jMlMO0+MLnYxwzZEE/7EHgva5tz0OEO1YNuq7u9dNTT0nISrRyuCHbQUEpRrRz/9dVnop0Y8ixdeVe7vWvCeAN0ntgKuSPHdLfYUAUoH8VAvcH8dygTjs47VgPdGRbo/cMotFb1DIkOzCiTJzoR4oFBuZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=q70FK54Y; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q70FK54Y" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-82f1fbe6899so6761b3a.0 for ; Thu, 16 Apr 2026 14:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776374264; x=1776979064; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ird1RbhcLmo1n1pSfDlmYxFmBRF3j4BNyuXGOX68NCU=; b=q70FK54YViXIXpJuaikoZYxg2xKb2W0PEU3gTf7E9f4UcF2I+nBTCHkJVIwmznLZvz k9qKpgYN2rfZMb/eowl0luvVUNeFc3c2wv/YGpFx/IGPEH93MTo/gRgklJUZ4RWuiMEG OT4I1BufWDpQEX/kT7CA9+i3sjHtoHtI61YOFgtdWuDkgni4JM+pOhY3ntAqCop2uoSA Hp9FIie8sVxBWE6ACoXxeBIL5H/5CTypV4ULIfKdTWtbooKcRxidYxZuGE0B0O6+mcpG I2ze6Pa4Ckpvx+b8FY9il9Z+Cd6xOdmLAd1oPguVwwaXJD0+PJM3kdV36ShlPxDkY7Jv mHBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776374264; x=1776979064; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ird1RbhcLmo1n1pSfDlmYxFmBRF3j4BNyuXGOX68NCU=; b=UpdK/mmdoERo9HCZujbDAcIMk74HEHu9DFjfFdBc9H2YsVI+GdDHMln4HisIGdlju9 jRqiRUus7f4PN8CNZ643B5OVgj+pZIGzwdehCSUsy5BsjLzx8brZiNdy4zJs9r2r1Sr6 gZPfGtC+WVTe4AOcTqmKZY5FfbMHNZM+0q70ziUFfyJHkq+ClCsrVgUxuqlYFpkkRJwg Tp/w2b5l2PqIyR8luqXJTf4umIDjnp6QJkrimZfBsQV5IWZS5yKG87Mf74ATD5w9qI37 2HB4UF1DPzSIosWTFerCuwDZlL0E5oFWzdU0P+ZItUxJkX0+DzALqgRAWXBxWjaIqXvs H5JA== X-Forwarded-Encrypted: i=1; AFNElJ9E7IFyEkH5AW4I6VLPWcCra6bUanss8tQaHwhW56/bObxOPC1EdvpFfE0QXxpGp8te+NhTbz3+Nx74MCw=@vger.kernel.org X-Gm-Message-State: AOJu0YxxmFXJ3RZ5tJs5h1m6ZJvgGh97bRXoXFht8n14H+fOIz2Zbf8F OKEqWfkNIFfA8Lwbowzi7Y3c+E8wrqhX5bcS0mtqsJpNmk7IKnrtXA6x X-Gm-Gg: AeBDievUWpohv4WlwstTp0/O0/qpEWTxXRnOU+yP2t/XSuQUN9GQvWx/HqkM6pKAGau FtTxtWKwKRJLfKw6bKNmWmC/1xJiI7HpMmTJX45HQnSCZm5ns8BmSnAyCsSHq8alBv/5stmrctl chk9Xe7moQYJOAxOyOWmUJOsF6s0pwB+WpAKRMoqMtCzdSEusSVepSm9xndk8ZDIphu5+0/JkQ9 fqRV4KryFP2TDpwdghvOd/4DtWBB0dLOOHNz3g/3Tq/I9lwogXTX8VIDhn8uxMNKLIJlWhLOlgf sGCdEGR5wwt3se0FC6uTYJcheTJfqHIiPkZRs0G0KySwE7VJCTHiXCqcP+aD49q5v83SPUf7ITi 8FaqpYbuIclbnRVVFCHHZ/8cPc0U5OEq4mE7kOn4pxf5ftrK8LkMceLeVKNLMfq0/SJfUovWYYl RWV+g98NvEVmGdcRh9fNXkTP2tHRc= X-Received: by 2002:a05:6a00:1994:b0:82c:24a9:d5e5 with SMTP id d2e1a72fcca58-82f88563412mr472762b3a.2.1776374263639; Thu, 16 Apr 2026 14:17:43 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f674140d3sm6134414b3a.44.2026.04.16.14.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2026 14:17:43 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon , Steve French Cc: Sergey Senozhatsky , Tom Talpey , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, DaeMyung Kang Subject: [PATCH] smb: server: fix max_connections off-by-one in tcp accept path Date: Fri, 17 Apr 2026 06:17:35 +0900 Message-ID: <20260416211735.3558718-1-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D1 rejects the first connection - max_connections=3D2 allows only one connection The per-IP limit in the same function uses <=3D 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 >=3D 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 --- fs/smb/server/transport_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c index 7e29b06820e2..5e85341698c7 100644 --- a/fs/smb/server/transport_tcp.c +++ b/fs/smb/server/transport_tcp.c @@ -279,7 +279,7 @@ static int ksmbd_kthread_fn(void *p) =20 skip_max_ip_conns_limit: if (server_conf.max_connections && - atomic_inc_return(&active_num_conn) >=3D server_conf.max_connections= ) { + atomic_inc_return(&active_num_conn) > server_conf.max_connections) { pr_info_ratelimited("Limit the maximum number of connections(%u)\n", atomic_read(&active_num_conn)); atomic_dec(&active_num_conn); --=20 2.43.0