* [PATCH net] xfrm: iptfs: only publish mode_data after clone setup
@ 2026-03-09 17:30 Paul Moses
2026-03-11 17:11 ` [net] " Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Paul Moses @ 2026-03-09 17:30 UTC (permalink / raw)
To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni
Cc: horms, chopps, netdev, linux-kernel, Paul Moses, stable
iptfs_clone_state() stores x->mode_data before allocating the reorder
window. If that allocation fails, the code frees the cloned state and
returns -ENOMEM, leaving x->mode_data pointing at freed memory.
The xfrm clone unwind later runs destroy_state() through x->mode_data,
so the failed clone path tears down IPTFS state that clone_state()
already freed.
Keep the cloned IPTFS state private until all allocations succeed so
failed clones leave x->mode_data unset. The destroy path already
handles a NULL mode_data pointer.
Fixes: 4b3faf610cc63 ("xfrm: iptfs: add new iptfs xfrm mode impl")
Cc: stable@vger.kernel.org
Signed-off-by: Paul Moses <p@1g4.org>
---
net/xfrm/xfrm_iptfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 050a82101ca51..4d7a925f59b7c 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -2653,9 +2653,6 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig)
if (!xtfs)
return -ENOMEM;
- x->mode_data = xtfs;
- xtfs->x = x;
-
xtfs->ra_newskb = NULL;
if (xtfs->cfg.reorder_win_size) {
xtfs->w_saved = kzalloc_objs(*xtfs->w_saved,
@@ -2666,6 +2663,9 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig)
}
}
+ x->mode_data = xtfs;
+ xtfs->x = x;
+
return 0;
}
--
2.53.GIT
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [net] xfrm: iptfs: only publish mode_data after clone setup
2026-03-09 17:30 [PATCH net] xfrm: iptfs: only publish mode_data after clone setup Paul Moses
@ 2026-03-11 17:11 ` Simon Horman
2026-03-11 18:47 ` Paul Moses
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2026-03-11 17:11 UTC (permalink / raw)
To: p
Cc: Simon Horman, edumazet, stable, herbert, linux-kernel, davem,
kuba, steffen.klassert, chopps, netdev, pabeni
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
xfrm: iptfs: only publish mode_data after clone setup
iptfs_clone_state() stores x->mode_data before allocating the reorder
window. If that allocation fails, the code frees the cloned state and
returns -ENOMEM, leaving x->mode_data pointing at freed memory. The xfrm
clone unwind later runs destroy_state() through x->mode_data, so the failed
clone path tears down IPTFS state that clone_state() already freed. Keep
the cloned IPTFS state private until all allocations succeed so failed
clones leave x->mode_data unset.
> Fixes: 4b3faf610cc63 ("xfrm: iptfs: add new iptfs xfrm mode impl")
Should this Fixes tag point to 6be02e3e4f37 instead?
The original commit 4b3faf610cc63 added a simple iptfs_clone_state() function
that did not have the buggy allocation pattern. Commit 6be02e3e4f37 ("xfrm:
iptfs: handle reordering of received packets") added the reorder window
allocation code (xtfs->w_saved) to iptfs_clone_state(), but set x->mode_data
BEFORE the allocation, creating a use-after-free bug when the allocation
fails.
Suggested: Fixes: 6be02e3e4f37 ("xfrm: iptfs: handle reordering of received
packets")
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [net] xfrm: iptfs: only publish mode_data after clone setup
2026-03-11 17:11 ` [net] " Simon Horman
@ 2026-03-11 18:47 ` Paul Moses
0 siblings, 0 replies; 3+ messages in thread
From: Paul Moses @ 2026-03-11 18:47 UTC (permalink / raw)
To: Simon Horman
Cc: edumazet, stable, herbert, linux-kernel, davem, kuba,
steffen.klassert, chopps, netdev, pabeni
>
> > Fixes: 4b3faf610cc63 ("xfrm: iptfs: add new iptfs xfrm mode impl")
>
> Should this Fixes tag point to 6be02e3e4f37 instead?
>
Yes
Thanks,
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-11 18:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 17:30 [PATCH net] xfrm: iptfs: only publish mode_data after clone setup Paul Moses
2026-03-11 17:11 ` [net] " Simon Horman
2026-03-11 18:47 ` Paul Moses
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox