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 Cc: stable@vger.kernel.org Signed-off-by: Theodor Arsenij Larionov Trichkine --- 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