* [PATCH nf v5] ipvs: ftp: do not link expectations to unconfirmed conntracks
@ 2026-11-18 15:17 Theodor Arsenij Larionov Trichkine
2026-11-18 15:35 ` Julian Anastasov
0 siblings, 1 reply; 2+ messages in thread
From: Theodor Arsenij Larionov Trichkine @ 2026-11-18 15:17 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
Check the conntrack at the start of ip_vs_ftp_out() and drop the packet
unless the conntrack is confirmed, is not a template and already carries
the seqadj extension.
Fixes: b25adce16064 ("ipvs: correct usage/allocation of seqadj ext in ipvs")
Suggested-by: Julian Anastasov <ja@ssi.bg>
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: stable@vger.kernel.org
Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
---
v5: drop the second nf_ct_get().
v4: check the conntrack at the start of ip_vs_ftp_out(). A server reply
that fails the check is now dropped even when it is not a PASV/EPSV
response. Without a conntrack, e.g. with a notrack rule, only PASV/EPSV
replies were dropped before.
Link to v4: https://lore.kernel.org/netfilter-devel/20261117123944.270667-1-theodorlarionov@gmail.com/
net/netfilter/ipvs/ip_vs_ftp.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index 44de99f4d187..cf640cba0b12 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -29,6 +29,7 @@
#include <linux/netfilter.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
#include <net/netfilter/nf_nat.h>
#include <net/netfilter/nf_nat_helper.h>
#include <linux/gfp.h>
@@ -283,6 +284,12 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
if (cp->state != IP_VS_TCP_S_ESTABLISHED)
return 1;
+ ct = nf_ct_get(skb, &ctinfo);
+ if (!ct || !nf_ct_is_confirmed(ct) || nf_ct_is_template(ct))
+ return 0;
+ if (!nfct_seqadj(ct))
+ return 0;
+
/* Linear packets are much easier to deal with. */
if (skb_ensure_writable(skb, skb->len))
return 0;
@@ -382,7 +389,6 @@ 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 && !nf_ct_is_template(ct)) {
bool mangled;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH nf v5] ipvs: ftp: do not link expectations to unconfirmed conntracks
2026-11-18 15:17 [PATCH nf v5] ipvs: ftp: do not link expectations to unconfirmed conntracks Theodor Arsenij Larionov Trichkine
@ 2026-11-18 15:35 ` Julian Anastasov
0 siblings, 0 replies; 2+ messages in thread
From: Julian Anastasov @ 2026-11-18 15:35 UTC (permalink / raw)
To: Theodor Arsenij Larionov Trichkine
Cc: Pablo Neira Ayuso, Simon Horman, Florian Westphal, Phil Sutter,
lvs-devel, netfilter-devel, netdev, coreteam
Hello,
On Wed, 18 Nov 2026, 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
>
> Check the conntrack at the start of ip_vs_ftp_out() and drop the packet
> unless the conntrack is confirmed, is not a template and already carries
> the seqadj extension.
>
> Fixes: b25adce16064 ("ipvs: correct usage/allocation of seqadj ext in ipvs")
> Suggested-by: Julian Anastasov <ja@ssi.bg>
> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
> ---
> v5: drop the second nf_ct_get().
> v4: check the conntrack at the start of ip_vs_ftp_out(). A server reply
> that fails the check is now dropped even when it is not a PASV/EPSV
> response. Without a conntrack, e.g. with a notrack rule, only PASV/EPSV
> replies were dropped before.
> Link to v4: https://lore.kernel.org/netfilter-devel/20261117123944.270667-1-theodorlarionov@gmail.com/
>
> net/netfilter/ipvs/ip_vs_ftp.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
> index 44de99f4d187..cf640cba0b12 100644
> --- a/net/netfilter/ipvs/ip_vs_ftp.c
> +++ b/net/netfilter/ipvs/ip_vs_ftp.c
> @@ -29,6 +29,7 @@
> #include <linux/netfilter.h>
> #include <net/netfilter/nf_conntrack.h>
> #include <net/netfilter/nf_conntrack_expect.h>
> +#include <net/netfilter/nf_conntrack_seqadj.h>
> #include <net/netfilter/nf_nat.h>
> #include <net/netfilter/nf_nat_helper.h>
> #include <linux/gfp.h>
> @@ -283,6 +284,12 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
> if (cp->state != IP_VS_TCP_S_ESTABLISHED)
> return 1;
>
> + ct = nf_ct_get(skb, &ctinfo);
> + if (!ct || !nf_ct_is_confirmed(ct) || nf_ct_is_template(ct))
> + return 0;
> + if (!nfct_seqadj(ct))
> + return 0;
> +
> /* Linear packets are much easier to deal with. */
> if (skb_ensure_writable(skb, skb->len))
> return 0;
> @@ -382,7 +389,6 @@ 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 && !nf_ct_is_template(ct)) {
> bool mangled;
Just drop the 'mangled' var and unindent the code:
/* If mangling fails this function will return 0 ...
...
if (nf_nat_mangle_tcp_packet(...
... )) {
ip_vs_nfct_expect_related(skb, ct, n_cp, ...
...
ret = 1;
}
because we do not need to check with nf_ct_is_template again.
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 15:17 [PATCH nf v5] ipvs: ftp: do not link expectations to unconfirmed conntracks Theodor Arsenij Larionov Trichkine
2026-11-18 15:35 ` Julian Anastasov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox