mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julian Anastasov <ja@ssi.bg>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: Simon Horman <horms@verge.net.au>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Florian Westphal <fw@strlen.de>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Phil Sutter <phil@nwl.cc>,
	netdev@vger.kernel.org, lvs-devel@vger.kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] netfilter: ipvs: fix ct refcount leak when template is invalid
Date: Thu, 28 May 2026 13:29:25 +0300 (EEST)	[thread overview]
Message-ID: <155bcc31-033b-18ec-8ff1-bb0d32e4b44a@ssi.bg> (raw)
In-Reply-To: <20260528072100.1163109-1-vulab@iscas.ac.cn>


	Hello,

On Thu, 28 May 2026, Wentao Liang wrote:

> ip_vs_sched_persist() calls ip_vs_ct_in_get() to look up an existing
> connection template, which returns ct with a reference held. If the
> template exists but fails the ip_vs_check_template() validation, the
> function can leak the reference in two ways:

	You missed the __ip_vs_conn_put(ct) in ip_vs_check_template()
when 0 is returned :) So, there is no leak.

> 
> 1. If no destination is found (scheduler returns NULL), the function
>    returns NULL at the !dest check without calling ip_vs_conn_put(ct).
> 
> 2. If a destination is found and a new template is created via
>    ip_vs_conn_new(), the old ct pointer is overwritten without its
>    reference being released.
> 
> Fix this by adding ip_vs_conn_put(ct) before the early return when no
> destination is found, and before overwriting ct with the new template.
> 
> Cc: stable@vger.kernel.org
> Fixes: 5b57a98c1f0d ("IPVS: compact ip_vs_sched_persist()")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  net/netfilter/ipvs/ip_vs_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index d40b404c1bf6..bdc3f296876a 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -536,6 +536,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
>  			IP_VS_DBG(1, "p-schedule: no dest found.\n");
>  			kfree(param.pe_data);
>  			*ignored = 0;
> +			ip_vs_conn_put(ct);
>  			return NULL;
>  		}
>  
> @@ -551,6 +552,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
>  		if (ct == NULL) {
>  			kfree(param.pe_data);
>  			*ignored = -1;
> +			ip_vs_conn_put(ct);
>  			return NULL;
>  		}
>  
> -- 
> 2.34.1

Regards

--
Julian Anastasov <ja@ssi.bg>


  reply	other threads:[~2026-05-28 10:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28  7:21 Wentao Liang
2026-05-28 10:29 ` Julian Anastasov [this message]
2026-05-28 14:27 ` [syzbot ci] " syzbot ci

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=155bcc31-033b-18ec-8ff1-bb0d32e4b44a@ssi.bg \
    --to=ja@ssi.bg \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@verge.net.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /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

all inboxes | Powered by JetHome®