Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Theodor Arsenij Larionov Trichki...
Mon, 16 Nov 2026 10:15
[PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
Author: Theodor Arsenij Larionov Trichki...
Date: Mon, 16 Nov 2026 10:15
Date: Mon, 16 Nov 2026 10:15
42 lines
12365 bytes
12365 bytes
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
Re: [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
Author: Pablo Neira Ayuso
Date: Mon, 16 Nov 2026 10:51
Date: Mon, 16 Nov 2026 10:51
49 lines
10104 bytes
10104 bytes
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
>
Re: [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
Author: Theodor Arsenij Larionov-Trichki...
Date: Mon, 16 Nov 2026 11:05
Date: Mon, 16 Nov 2026 11:05
10 lines
12348 bytes
12348 bytes
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?
Re: [PATCH nf v3] ipvs: ftp: do not link expectations to unconfirmed conntracks
Author: Pablo Neira Ayuso
Date: Mon, 16 Nov 2026 11:17
Date: Mon, 16 Nov 2026 11:17
31 lines
9618 bytes
9618 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads