Skip to content

Commit d849a2f

Browse files
jopamoklassert
authored andcommitted
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. The destroy path already handles a NULL mode_data pointer. Fixes: 6be02e3 ("xfrm: iptfs: handle reordering of received packets") Cc: [email protected] Signed-off-by: Paul Moses <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent eb2d16a commit d849a2f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

net/xfrm/xfrm_iptfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,9 +2664,6 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig)
26642664
if (!xtfs)
26652665
return -ENOMEM;
26662666

2667-
x->mode_data = xtfs;
2668-
xtfs->x = x;
2669-
26702667
xtfs->ra_newskb = NULL;
26712668
if (xtfs->cfg.reorder_win_size) {
26722669
xtfs->w_saved = kcalloc(xtfs->cfg.reorder_win_size,
@@ -2677,6 +2674,9 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig)
26772674
}
26782675
}
26792676

2677+
x->mode_data = xtfs;
2678+
xtfs->x = x;
2679+
26802680
return 0;
26812681
}
26822682

0 commit comments

Comments
 (0)