Netdev List
 help / color / mirror / Atom feed
* [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
@ 2026-11-16 10:15 Theodor Arsenij Larionov Trichkine
  2026-11-16 10:51 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Theodor Arsenij Larionov Trichkine @ 2026-11-16 10:15 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Julian Anastasov, Simon Horman, Florian Westphal, Phil Sutter,
	lvs-devel, netfilter-devel, netdev, coreteam,
	Theodor Arsenij Larionov Trichkine

ip_vs_ftp_out() can link an expectation to an unconfirmed conntrack. A
later extension add on the same packet, such as seqadj in
ip_vs_update_conntrack() or NAT, then reallocates ct->ext and leaves the
expectation pointing into the freed area:

  BUG: KASAN: slab-use-after-free in nf_ct_unlink_expect_report+0x490/0x4c0
  Write of size 8 at addr ffff888004dd4e48 by task syz.2.17/649

Link the expectation only to a confirmed conntrack.

Fixes: b25adce16064 ("ipvs: correct usage/allocation of seqadj ext in ipvs")
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: stable@vger.kernel.org
Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
---
v3: skip unconfirmed conntracks, as suggested by Pablo; v2 did not
cover NAT.
v2: https://lore.kernel.org/netdev/20261113011447.2357709-8-pablo@netfilter.org/

 net/netfilter/ipvs/ip_vs_ftp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 44de99f4d187..cb0cdc35a7c1 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -398,8 +398,10 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
 						   end - start,
 						   buf, buf_len);
 		if (mangled) {
-			ip_vs_nfct_expect_related(skb, ct, n_cp,
-						  ipvsh->protocol, 0, 0);
+			if (nf_ct_is_confirmed(ct))
+				ip_vs_nfct_expect_related(skb, ct, n_cp,
+							  ipvsh->protocol,
+							  0, 0);
 			if (skb->ip_summed == CHECKSUM_COMPLETE)
 				skb->ip_summed = CHECKSUM_UNNECESSARY;
 			/* csum is updated */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
  2026-11-16 10:15 [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks Theodor Arsenij Larionov Trichkine
@ 2026-11-16 10:51 ` Pablo Neira Ayuso
  2026-11-16 11:05   ` Theodor Arsenij Larionov-Trichkine
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-11-16 10:51 UTC (permalink / raw)
  To: Theodor Arsenij Larionov Trichkine
  Cc: Julian Anastasov, Simon Horman, Florian Westphal, Phil Sutter,
	lvs-devel, netfilter-devel, netdev, coreteam

On Mon, Nov 16, 2026 at 01:15:06PM +0300, Theodor Arsenij Larionov Trichkine wrote:
> ip_vs_ftp_out() can link an expectation to an unconfirmed conntrack. A
> later extension add on the same packet, such as seqadj in
> ip_vs_update_conntrack() or NAT, then reallocates ct->ext and leaves the
> expectation pointing into the freed area:
> 
>   BUG: KASAN: slab-use-after-free in nf_ct_unlink_expect_report+0x490/0x4c0
>   Write of size 8 at addr ffff888004dd4e48 by task syz.2.17/649
> 
> Link the expectation only to a confirmed conntrack.
> 
> Fixes: b25adce16064 ("ipvs: correct usage/allocation of seqadj ext in ipvs")
> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
> ---
> v3: skip unconfirmed conntracks, as suggested by Pablo; v2 did not
> cover NAT.
> v2: https://lore.kernel.org/netdev/20261113011447.2357709-8-pablo@netfilter.org/
> 
>  net/netfilter/ipvs/ip_vs_ftp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
> index 44de99f4d187..cb0cdc35a7c1 100644
> --- a/net/netfilter/ipvs/ip_vs_ftp.c
> +++ b/net/netfilter/ipvs/ip_vs_ftp.c
> @@ -398,8 +398,10 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
>  						   end - start,
>  						   buf, buf_len);
>  		if (mangled) {
> -			ip_vs_nfct_expect_related(skb, ct, n_cp,
> -						  ipvsh->protocol, 0, 0);
> +			if (nf_ct_is_confirmed(ct))

I think this is coming a bit late?

Maybe it is possible to check this earlier in this path?

> +				ip_vs_nfct_expect_related(skb, ct, n_cp,
> +							  ipvsh->protocol,
> +							  0, 0);
>  			if (skb->ip_summed == CHECKSUM_COMPLETE)
>  				skb->ip_summed = CHECKSUM_UNNECESSARY;
>  			/* csum is updated */
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
  2026-11-16 10:51 ` Pablo Neira Ayuso
@ 2026-11-16 11:05   ` Theodor Arsenij Larionov-Trichkine
  2026-11-16 11:17     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Theodor Arsenij Larionov-Trichkine @ 2026-11-16 11:05 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Julian Anastasov, Simon Horman, Florian Westphal, Phil Sutter,
	lvs-devel, netfilter-devel, netdev, coreteam

On Mon, Nov 16, 2026 at 1:51 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> I think this is coming a bit late?
>
> Maybe it is possible to check this earlier in this path?

You mean returning at the top of ip_vs_ftp_out() if the ct is not
confirmed, and letting the packet through untouched? Or even before
ip_vs_ftp_out() gets called?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
  2026-11-16 11:05   ` Theodor Arsenij Larionov-Trichkine
@ 2026-11-16 11:17     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-11-16 11:17 UTC (permalink / raw)
  To: Theodor Arsenij Larionov-Trichkine
  Cc: Julian Anastasov, Simon Horman, Florian Westphal, Phil Sutter,
	lvs-devel, netfilter-devel, netdev, coreteam

On Mon, Nov 16, 2026 at 02:05:52PM +0300, Theodor Arsenij Larionov-Trichkine wrote:
> On Mon, Nov 16, 2026 at 1:51 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > I think this is coming a bit late?
> >
> > Maybe it is possible to check this earlier in this path?
> 
> You mean returning at the top of ip_vs_ftp_out() if the ct is not
> confirmed, and letting the packet through untouched? Or even before
> ip_vs_ftp_out() gets called?

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 9e3e005a8263..5d7b572961f9 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -368,7 +368,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
        buf_len = strlen(buf);
 
        ct = nf_ct_get(skb, &ctinfo);
-       if (ct) {
+       if (ct && !nf_ct_unconfirmed(ct)) {
                bool mangled;
 
                /* If mangling fails this function will return 0

IIRC, there is a recent fix here to ignore template conntracks too
here.

@Julian, is it worth all the pattern matching before getting here
worth if the ct is unconfirmed? Otherwise, this can be short-circuit
earlier.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-16 11:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 10:15 [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks Theodor Arsenij Larionov Trichkine
2026-11-16 10:51 ` Pablo Neira Ayuso
2026-11-16 11:05   ` Theodor Arsenij Larionov-Trichkine
2026-11-16 11:17     ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox