netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antony Antony <antony.antony@secunet.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
	<netdev@vger.kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>
Cc: Antony Antony <antony@phenome.org>,
	Antony Antony <antony.antony@secunet.com>
Subject: [PATCH v3 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate
Date: Fri, 4 Sep 2020 08:49:55 +0200	[thread overview]
Message-ID: <20200904064955.GA21521@moon.secunet.de> (raw)
In-Reply-To: <20200820181158.GA19658@moon.secunet.de>

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: af2f464e326e ("xfrm: Assign esn pointers when cloning a state")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
 include/net/xfrm.h | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 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;
 }
-- 
2.20.1


  parent reply	other threads:[~2020-09-04  6:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
2020-08-20 18:14 ` [PATCH 2/3] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate Antony Antony
2020-08-24  8:43   ` Steffen Klassert
2020-08-20 18:16 ` [PATCH 3/3] xfrm: clone XFRMA_SEC_CTX during xfrm_do_migrate Antony Antony
2020-08-24  8:46   ` Steffen Klassert
2020-08-24  8:39 ` [PATCH 1/3] xfrm: clone XFRMA_SET_MARK " Steffen Klassert
2020-08-26 19:39 ` [PATCH v2 1/4] xfrm: clone XFRMA_SET_MARK in xfrm_do_migrate Antony Antony
2020-08-26 19:39 ` [PATCH v2 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL " Antony Antony
2020-08-26 19:40 ` [PATCH v2 3/4] xfrm: clone XFRMA_SEC_CTX " Antony Antony
2020-08-28  5:18   ` Steffen Klassert
2020-08-26 19:40 ` [PATCH v2 4/4] xfrm: clone whole liftime_cur structure " Antony Antony
2020-08-28  5:20   ` Steffen Klassert
2020-09-04  6:49 ` [PATCH v3 1/4] xfrm: clone XFRMA_SET_MARK " Antony Antony
2020-09-09  5:54   ` Steffen Klassert
2020-09-04  6:49 ` Antony Antony [this message]
2020-09-04  6:50 ` [PATCH v3 3/4] xfrm: clone XFRMA_SEC_CTX " Antony Antony
2020-09-04  6:50 ` [PATCH v3 4/4] xfrm: clone whole liftime_cur structure " Antony Antony

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200904064955.GA21521@moon.secunet.de \
    --to=antony.antony@secunet.com \
    --cc=antony@phenome.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).