diff mbox series

[2/3] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate

Message ID 20200820181452.GA19740@moon.secunet.de
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series [1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate | expand

Commit Message

Antony Antony Aug. 20, 2020, 6:14 p.m. UTC
XFRMA_REPLAY_ESN_VAL was not cloned from the old to the new.
Migrate this attribute during XFRMA_MSG_MIGRATE

Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
 include/net/xfrm.h    | 16 ++++++----------
 net/xfrm/xfrm_state.c |  2 +-
 2 files changed, 7 insertions(+), 11 deletions(-)

Comments

Steffen Klassert Aug. 24, 2020, 8:43 a.m. UTC | #1
On Thu, Aug 20, 2020 at 08:14:52PM +0200, Antony Antony wrote:
> XFRMA_REPLAY_ESN_VAL was not cloned from the old to the new.
> Migrate this attribute during XFRMA_MSG_MIGRATE
> 
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
> ---
>  include/net/xfrm.h    | 16 ++++++----------
>  net/xfrm/xfrm_state.c |  2 +-
>  2 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/include/net/xfrm.h b/include/net/xfrm.h
> index 2737d24ec244..9e806c781025 100644
> --- a/include/net/xfrm.h
> +++ b/include/net/xfrm.h
> @@ -1773,21 +1773,17 @@ static inline unsigned int xfrm_replay_state_esn_len(struct xfrm_replay_state_es
>  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;
>  }
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 3a000f289dcd..20a12c67a931 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1522,7 +1522,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
>  	x->tfcpad = orig->tfcpad;
>  	x->replay_maxdiff = orig->replay_maxdiff;
>  	x->replay_maxage = orig->replay_maxage;
> -	x->curlft.add_time = orig->curlft.add_time;
> +	x->curlft = orig->curlft;

That change seems not to belong to this patch.
Also please add a 'Fixes' tag.
diff mbox series

Patch

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 2737d24ec244..9e806c781025 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1773,21 +1773,17 @@  static inline unsigned int xfrm_replay_state_esn_len(struct xfrm_replay_state_es
 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;
 }
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 3a000f289dcd..20a12c67a931 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1522,7 +1522,7 @@  static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
 	x->tfcpad = orig->tfcpad;
 	x->replay_maxdiff = orig->replay_maxdiff;
 	x->replay_maxage = orig->replay_maxage;
-	x->curlft.add_time = orig->curlft.add_time;
+	x->curlft = orig->curlft;
 	x->km.state = orig->km.state;
 	x->km.seq = orig->km.seq;
 	x->replay = orig->replay;