[{"id":3678436,"web_url":"http://patchwork.ozlabs.org/comment/3678436/","msgid":"<CAKYAXd-P=E+bc+3W4DffU4SRtBDysJ+0yhmsxX7LvNB_8vR=sQ@mail.gmail.com>","list_archive_url":null,"date":"2026-04-16T23:36:44","subject":"Re: [PATCH] smb: server: fix max_connections off-by-one in tcp accept\n path","submitter":{"id":79386,"url":"http://patchwork.ozlabs.org/api/people/79386/","name":"Namjae Jeon","email":"linkinjeon@kernel.org"},"content":"On Fri, Apr 17, 2026 at 6:17 AM DaeMyung Kang <charsyam@gmail.com> wrote:\n>\n> The global max_connections check in ksmbd's TCP accept path counts\n> the newly accepted connection with atomic_inc_return(), but then\n> rejects the connection when the result is greater than or equal to\n> server_conf.max_connections.\n>\n> That makes the effective limit one smaller than configured. For\n> example:\n>\n> - max_connections=1 rejects the first connection\n> - max_connections=2 allows only one connection\n>\n> The per-IP limit in the same function uses <= correctly because it\n> counts only pre-existing connections. The global limit instead checks\n> the post-increment total, so it should reject only when that total\n> exceeds the configured maximum.\n>\n> Fix this by changing the comparison from >= to >, so exactly\n> max_connections simultaneous connections are allowed and the next one\n> is rejected. This matches the documented meaning of max_connections\n> in fs/smb/server/ksmbd_netlink.h as the \"Number of maximum simultaneous\n> connections\".\n>\n> Fixes: 0d0d4680db22 (\"ksmbd: add max connections parameter\")\n> Cc: stable@vger.kernel.org\n> Signed-off-by: DaeMyung Kang <charsyam@gmail.com>\nApplied it to #ksmbd-for-next-next.\nThanks!","headers":{"Return-Path":"\n <linux-cifs+bounces-10880-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=nHSY6H4H;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10880-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"nHSY6H4H\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxZFK0pr1z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 09:37:57 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 3858D305A10A\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 23:36:59 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5127B38657C;\n\tThu, 16 Apr 2026 23:36:58 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DCD9382284\n\tfor <linux-cifs@vger.kernel.org>; Thu, 16 Apr 2026 23:36:57 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id CCB3EC2BCAF\n\tfor <linux-cifs@vger.kernel.org>; Thu, 16 Apr 2026 23:36:57 +0000 (UTC)","by mail-ed1-f53.google.com with SMTP id\n 4fb4d7f45d1cf-672bd8d2400so108402a12.1\n        for <linux-cifs@vger.kernel.org>;\n Thu, 16 Apr 2026 16:36:57 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776382618; cv=none;\n b=tHWkXkG/XtdLva2ey7wCO+jreH5moRIY+AlCCfZ41FwMipwG3v/p2axgxesuuIDtOZMXBUSem9hsbl+l+9yjIxVb6+dKt173WJoGEnXWqIWYp43ygPV0Jxn+AQKwEiQxAHtmVlhcZafpMSfmgJY7NbmzGCKomkAe5RiuZeFl7DQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776382618; c=relaxed/simple;\n\tbh=Ia4Z1gW6inXqBnNjZ5tfjmiMCPXDFFfczDlGe0Y3rA4=;\n\th=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:\n\t To:Cc:Content-Type;\n b=H722NOZgnboxsH1ngHmh9wY82WY0+7iWAPBLn5EfeLHv7cveCr5TZo1SsmNvCKNXMbPJLnzWJdVz79rFv169dazJRAbfHWKmrzN8IlP2m62NepnzNvo6oHypERPhr9EsmjFtcB2+K29Egl71ecrD7ScZ9By9GG0lZIMAl1KIlUE=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=nHSY6H4H; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776382617;\n\tbh=Ia4Z1gW6inXqBnNjZ5tfjmiMCPXDFFfczDlGe0Y3rA4=;\n\th=References:In-Reply-To:From:Date:Subject:To:Cc:From;\n\tb=nHSY6H4HzrjG1B7ncgE10nhlBQ7WknRrHPKmbUNXlcwrnhGRl5eVmTSHviyuJXp8k\n\t /G+r62TmWTB0kXX+HVImcHx1VusvuKkQjUrKW58VayWTwUGBOKGc4uwzodgJsqA7wf\n\t LI/WAQ8QejwDcnGhm6duFABlx4t89+R3CJtbq8PSOJTJEsE4QSDvConlxbRu7JAD6B\n\t Xq+MNiG/6yTPLX8Kfm4j4pwHOLUfFVpqLPsygAl7Jp6Nkr3QkP7LQlHNUjDJ4TeI9V\n\t KSs46Xda+FSfm7ENDBrbKt/VbnqaNPuTO3x8YjIe77otNHZHtEVj/bq7l7QJgnFGgu\n\t IB7INjhGlrZ/w==","X-Forwarded-Encrypted":"i=1;\n AFNElJ/JdE8vpPNpi1KgsrqwhnQln1/krbhHS5VlQupxbS8JBdXatBVOtebRr+LloDh3VQpc5dfkGk6Evi46@vger.kernel.org","X-Gm-Message-State":"AOJu0YyFM950PYZIQibTj4LVn2kl4LFCPeZ4LraAm/iagw0pjugqh9mh\n\tK/KeSzQHLeWjHX+wsWUQw0DPzaZ2tG6PGXv1w5YKLOs4cXkCNlk5Pyo6Um+f1JWjyaSl+z4ofh2\n\tiBX4ZAuuLpiQYXs0+vgoLiCQo341BXAo=","X-Received":"by 2002:a05:6402:24cd:b0:66b:aa56:ee5c with SMTP id\n 4fb4d7f45d1cf-672bffd3a22mr237465a12.28.1776382616452; Thu, 16 Apr 2026\n 16:36:56 -0700 (PDT)","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","References":"<20260416211735.3558718-1-charsyam@gmail.com>","In-Reply-To":"<20260416211735.3558718-1-charsyam@gmail.com>","From":"Namjae Jeon <linkinjeon@kernel.org>","Date":"Fri, 17 Apr 2026 08:36:44 +0900","X-Gmail-Original-Message-ID":"\n <CAKYAXd-P=E+bc+3W4DffU4SRtBDysJ+0yhmsxX7LvNB_8vR=sQ@mail.gmail.com>","X-Gm-Features":"AQROBzB66y9CrUgy1WHZWYxRh_RXy7Qc-7PMcqfpOvkbqt64rMF7nxAIdWWdei4","Message-ID":"\n <CAKYAXd-P=E+bc+3W4DffU4SRtBDysJ+0yhmsxX7LvNB_8vR=sQ@mail.gmail.com>","Subject":"Re: [PATCH] smb: server: fix max_connections off-by-one in tcp accept\n path","To":"DaeMyung Kang <charsyam@gmail.com>","Cc":"Steve French <smfrench@gmail.com>,\n Sergey Senozhatsky <senozhatsky@chromium.org>,\n\tTom Talpey <tom@talpey.com>, linux-cifs@vger.kernel.org,\n linux-kernel@vger.kernel.org,\n\tstable@vger.kernel.org","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable"}}]