Skip to content

Commit

Permalink
xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate
Browse files Browse the repository at this point in the history
[ Upstream commit 91a46c6 ]

XFRMA_REPLAY_ESN_VAL was not cloned completely from the old to the new.
Migrate this attribute during XFRMA_MSG_MIGRATE

v1->v2:
 - move curleft cloning to a separate patch

Fixes: af2f464 ("xfrm: Assign esn pointers when cloning a state")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Antony Antony authored and Greg Kroah-Hartman committed Oct 14, 2020
1 parent 171dfb5 commit a9326ec
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions include/net/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1726,21 +1726,17 @@ static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay
static inline int xfrm_replay_clone(struct xfrm_state *x,
struct xfrm_state *orig)
{
x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn),

x->replay_esn = kmemdup(orig->replay_esn,
xfrm_replay_state_esn_len(orig->replay_esn),
GFP_KERNEL);
if (!x->replay_esn)
return -ENOMEM;

x->replay_esn->bmp_len = orig->replay_esn->bmp_len;
x->replay_esn->replay_window = orig->replay_esn->replay_window;

x->preplay_esn = kmemdup(x->replay_esn,
xfrm_replay_state_esn_len(x->replay_esn),
x->preplay_esn = kmemdup(orig->preplay_esn,
xfrm_replay_state_esn_len(orig->preplay_esn),
GFP_KERNEL);
if (!x->preplay_esn) {
kfree(x->replay_esn);
if (!x->preplay_esn)
return -ENOMEM;
}

return 0;
}
Expand Down

0 comments on commit a9326ec

Please sign in to comment.