Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate
@ 2020-08-20 18:11 Antony Antony
2020-08-20 18:14 ` [PATCH 2/3] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate Antony Antony
` (10 more replies)
0 siblings, 11 replies; 17+ messages in thread
From: Antony Antony @ 2020-08-20 18:11 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony
XFRMA_SET_MARK and XFRMA_SET_MARK_MASK was not cloned from the old
to the new. Migrate these two attributes during XFRMA_MSG_MIGRATE
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 69520ad3d83b..3a000f289dcd 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1510,6 +1510,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
}
memcpy(&x->mark, &orig->mark, sizeof(x->mark));
+ memcpy(&x->props.smark, &orig->props.smark, sizeof(x->props.smark));
if (xfrm_init_state(x) < 0)
goto error;
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 2/3] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
@ 2020-08-20 18:14 ` 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
` (9 subsequent siblings)
10 siblings, 1 reply; 17+ messages in thread
From: Antony Antony @ 2020-08-20 18:14 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony
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;
x->km.state = orig->km.state;
x->km.seq = orig->km.seq;
x->replay = orig->replay;
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 3/3] xfrm: clone XFRMA_SEC_CTX during xfrm_do_migrate
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-20 18:16 ` Antony Antony
2020-08-24 8:46 ` Steffen Klassert
2020-08-24 8:39 ` [PATCH 1/3] xfrm: clone XFRMA_SET_MARK " Steffen Klassert
` (8 subsequent siblings)
10 siblings, 1 reply; 17+ messages in thread
From: Antony Antony @ 2020-08-20 18:16 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
XFRMA_SEC_CTX 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>
---
net/xfrm/xfrm_state.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 20a12c67a931..dbcb71b800b8 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1441,6 +1441,30 @@ int xfrm_state_add(struct xfrm_state *x)
EXPORT_SYMBOL(xfrm_state_add);
#ifdef CONFIG_XFRM_MIGRATE
+static inline bool clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security)
+{
+ struct xfrm_user_sec_ctx *uctx;
+ int size = sizeof(*uctx) + security->ctx_len;
+ int err;
+
+ uctx = kmalloc(size, GFP_KERNEL);
+ if (!uctx)
+ return true;
+
+ uctx->exttype = XFRMA_SEC_CTX;
+ uctx->len = size;
+ uctx->ctx_doi = security->ctx_doi;
+ uctx->ctx_alg = security->ctx_alg;
+ uctx->ctx_len = security->ctx_len;
+ memcpy(uctx + 1, security->ctx_str, security->ctx_len);
+ err = security_xfrm_state_alloc(x, uctx);
+ kfree(uctx);
+ if (err)
+ return true;
+
+ return false;
+}
+
static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
struct xfrm_encap_tmpl *encap)
{
@@ -1497,6 +1521,10 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
goto error;
}
+ if (orig->security)
+ if (clone_security(x, orig->security))
+ goto error;
+
if (orig->coaddr) {
x->coaddr = kmemdup(orig->coaddr, sizeof(*x->coaddr),
GFP_KERNEL);
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate
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-20 18:16 ` [PATCH 3/3] xfrm: clone XFRMA_SEC_CTX during xfrm_do_migrate Antony Antony
@ 2020-08-24 8:39 ` Steffen Klassert
2020-08-26 19:39 ` [PATCH v2 1/4] xfrm: clone XFRMA_SET_MARK in xfrm_do_migrate Antony Antony
` (7 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Steffen Klassert @ 2020-08-24 8:39 UTC (permalink / raw)
To: Antony Antony; +Cc: netdev, Herbert Xu, Antony Antony
On Thu, Aug 20, 2020 at 08:11:58PM +0200, Antony Antony wrote:
> XFRMA_SET_MARK and XFRMA_SET_MARK_MASK was not cloned from the old
> to the new. Migrate these two attributes during XFRMA_MSG_MIGRATE
>
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
Please add a 'Fixes' tag so that this can be backported
properly to the stable trees.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/3] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate
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
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Klassert @ 2020-08-24 8:43 UTC (permalink / raw)
To: Antony Antony; +Cc: netdev, Herbert Xu, Antony Antony
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.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/3] xfrm: clone XFRMA_SEC_CTX during xfrm_do_migrate
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
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Klassert @ 2020-08-24 8:46 UTC (permalink / raw)
To: Antony Antony; +Cc: netdev, Herbert Xu, Antony Antony
On Thu, Aug 20, 2020 at 08:16:08PM +0200, Antony Antony wrote:
> XFRMA_SEC_CTX 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>
> ---
> net/xfrm/xfrm_state.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 20a12c67a931..dbcb71b800b8 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1441,6 +1441,30 @@ int xfrm_state_add(struct xfrm_state *x)
> EXPORT_SYMBOL(xfrm_state_add);
>
> #ifdef CONFIG_XFRM_MIGRATE
> +static inline bool clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security)
> +{
> + struct xfrm_user_sec_ctx *uctx;
> + int size = sizeof(*uctx) + security->ctx_len;
> + int err;
> +
> + uctx = kmalloc(size, GFP_KERNEL);
> + if (!uctx)
> + return true;
> +
> + uctx->exttype = XFRMA_SEC_CTX;
> + uctx->len = size;
> + uctx->ctx_doi = security->ctx_doi;
> + uctx->ctx_alg = security->ctx_alg;
> + uctx->ctx_len = security->ctx_len;
> + memcpy(uctx + 1, security->ctx_str, security->ctx_len);
> + err = security_xfrm_state_alloc(x, uctx);
> + kfree(uctx);
> + if (err)
> + return true;
Returning 'true' on memory allocation errors is a bit odd,
please return -ENOMEM instead.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 1/4] xfrm: clone XFRMA_SET_MARK in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (2 preceding siblings ...)
2020-08-24 8:39 ` [PATCH 1/3] xfrm: clone XFRMA_SET_MARK " Steffen Klassert
@ 2020-08-26 19:39 ` Antony Antony
2020-08-26 19:39 ` [PATCH v2 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL " Antony Antony
` (6 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Antony Antony @ 2020-08-26 19:39 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
XFRMA_SET_MARK and XFRMA_SET_MARK_MASK was not cloned from the old
to the new. Migrate these two attributes during XFRMA_MSG_MIGRATE
Fixes: 9b42c1f179a6 ("xfrm: Extend the output_mark to support input direction and masking.")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 69520ad3d83b..3a000f289dcd 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1510,6 +1510,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
}
memcpy(&x->mark, &orig->mark, sizeof(x->mark));
+ memcpy(&x->props.smark, &orig->props.smark, sizeof(x->props.smark));
if (xfrm_init_state(x) < 0)
goto error;
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (3 preceding siblings ...)
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 ` Antony Antony
2020-08-26 19:40 ` [PATCH v2 3/4] xfrm: clone XFRMA_SEC_CTX " Antony Antony
` (5 subsequent siblings)
10 siblings, 0 replies; 17+ messages in thread
From: Antony Antony @ 2020-08-26 19:39 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
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 seperate 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
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 3/4] xfrm: clone XFRMA_SEC_CTX in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (4 preceding siblings ...)
2020-08-26 19:39 ` [PATCH v2 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL " Antony Antony
@ 2020-08-26 19:40 ` 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
` (4 subsequent siblings)
10 siblings, 1 reply; 17+ messages in thread
From: Antony Antony @ 2020-08-26 19:40 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
XFRMA_SEC_CTX was not cloned from the old to the new.
Migrate this attribute during XFRMA_MSG_MIGRATE
v1->v2:
- return -ENOMEM on error
Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 3a000f289dcd..16988303aed6 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1441,6 +1441,30 @@ int xfrm_state_add(struct xfrm_state *x)
EXPORT_SYMBOL(xfrm_state_add);
#ifdef CONFIG_XFRM_MIGRATE
+static inline bool clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security)
+{
+ struct xfrm_user_sec_ctx *uctx;
+ int size = sizeof(*uctx) + security->ctx_len;
+ int err;
+
+ uctx = kmalloc(size, GFP_KERNEL);
+ if (!uctx)
+ return -ENOMEM;
+
+ uctx->exttype = XFRMA_SEC_CTX;
+ uctx->len = size;
+ uctx->ctx_doi = security->ctx_doi;
+ uctx->ctx_alg = security->ctx_alg;
+ uctx->ctx_len = security->ctx_len;
+ memcpy(uctx + 1, security->ctx_str, security->ctx_len);
+ err = security_xfrm_state_alloc(x, uctx);
+ kfree(uctx);
+ if (err)
+ return err;
+
+ return 0;
+}
+
static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
struct xfrm_encap_tmpl *encap)
{
@@ -1497,6 +1521,10 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
goto error;
}
+ if (orig->security)
+ if (clone_security(x, orig->security))
+ goto error;
+
if (orig->coaddr) {
x->coaddr = kmemdup(orig->coaddr, sizeof(*x->coaddr),
GFP_KERNEL);
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 4/4] xfrm: clone whole liftime_cur structure in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (5 preceding siblings ...)
2020-08-26 19:40 ` [PATCH v2 3/4] xfrm: clone XFRMA_SEC_CTX " Antony Antony
@ 2020-08-26 19:40 ` 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
` (3 subsequent siblings)
10 siblings, 1 reply; 17+ messages in thread
From: Antony Antony @ 2020-08-26 19:40 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
When we clone state only add_time was cloned. It missed values like
bytes, packets. Now clone the all members of the structure.
Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 16988303aed6..64eb4a6fcfc2 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1550,7 +1550,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;
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 3/4] xfrm: clone XFRMA_SEC_CTX in xfrm_do_migrate
2020-08-26 19:40 ` [PATCH v2 3/4] xfrm: clone XFRMA_SEC_CTX " Antony Antony
@ 2020-08-28 5:18 ` Steffen Klassert
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Klassert @ 2020-08-28 5:18 UTC (permalink / raw)
To: Antony Antony; +Cc: netdev, Herbert Xu, Antony Antony
On Wed, Aug 26, 2020 at 09:40:09PM +0200, Antony Antony wrote:
> XFRMA_SEC_CTX was not cloned from the old to the new.
> Migrate this attribute during XFRMA_MSG_MIGRATE
>
> v1->v2:
> - return -ENOMEM on error
>
> Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
> ---
> net/xfrm/xfrm_state.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 3a000f289dcd..16988303aed6 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1441,6 +1441,30 @@ int xfrm_state_add(struct xfrm_state *x)
> EXPORT_SYMBOL(xfrm_state_add);
>
> #ifdef CONFIG_XFRM_MIGRATE
> +static inline bool clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security)
> +{
> + struct xfrm_user_sec_ctx *uctx;
> + int size = sizeof(*uctx) + security->ctx_len;
> + int err;
> +
> + uctx = kmalloc(size, GFP_KERNEL);
> + if (!uctx)
> + return -ENOMEM;
Now that this function returns error values, it should be
of type 'int' not 'bool'.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 4/4] xfrm: clone whole liftime_cur structure in xfrm_do_migrate
2020-08-26 19:40 ` [PATCH v2 4/4] xfrm: clone whole liftime_cur structure " Antony Antony
@ 2020-08-28 5:20 ` Steffen Klassert
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Klassert @ 2020-08-28 5:20 UTC (permalink / raw)
To: Antony Antony; +Cc: netdev, Herbert Xu, Antony Antony
On Wed, Aug 26, 2020 at 09:40:40PM +0200, Antony Antony wrote:
> When we clone state only add_time was cloned. It missed values like
> bytes, packets. Now clone the all members of the structure.
>
> Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
> ---
> net/xfrm/xfrm_state.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> index 16988303aed6..64eb4a6fcfc2 100644
> --- a/net/xfrm/xfrm_state.c
> +++ b/net/xfrm/xfrm_state.c
> @@ -1550,7 +1550,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;
You should use memcpy if you want to copy the whole structure.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/4] xfrm: clone XFRMA_SET_MARK in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (6 preceding siblings ...)
2020-08-26 19:40 ` [PATCH v2 4/4] xfrm: clone whole liftime_cur structure " Antony Antony
@ 2020-09-04 6:49 ` Antony Antony
2020-09-09 5:54 ` Steffen Klassert
2020-09-04 6:49 ` [PATCH v3 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL " Antony Antony
` (2 subsequent siblings)
10 siblings, 1 reply; 17+ messages in thread
From: Antony Antony @ 2020-09-04 6:49 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
XFRMA_SET_MARK and XFRMA_SET_MARK_MASK was not cloned from the old
to the new. Migrate these two attributes during XFRMA_MSG_MIGRATE
Fixes: 9b42c1f179a6 ("xfrm: Extend the output_mark to support input direction and masking.")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 69520ad3d83b..3a000f289dcd 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1510,6 +1510,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
}
memcpy(&x->mark, &orig->mark, sizeof(x->mark));
+ memcpy(&x->props.smark, &orig->props.smark, sizeof(x->props.smark));
if (xfrm_init_state(x) < 0)
goto error;
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (7 preceding siblings ...)
2020-09-04 6:49 ` [PATCH v3 1/4] xfrm: clone XFRMA_SET_MARK " Antony Antony
@ 2020-09-04 6:49 ` Antony Antony
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
10 siblings, 0 replies; 17+ messages in thread
From: Antony Antony @ 2020-09-04 6:49 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 3/4] xfrm: clone XFRMA_SEC_CTX in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (8 preceding siblings ...)
2020-09-04 6:49 ` [PATCH v3 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL " Antony Antony
@ 2020-09-04 6:50 ` Antony Antony
2020-09-04 6:50 ` [PATCH v3 4/4] xfrm: clone whole liftime_cur structure " Antony Antony
10 siblings, 0 replies; 17+ messages in thread
From: Antony Antony @ 2020-09-04 6:50 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
XFRMA_SEC_CTX was not cloned from the old to the new.
Migrate this attribute during XFRMA_MSG_MIGRATE
v1->v2:
- return -ENOMEM on error
v2->v3:
- fix return type to int
Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 3a000f289dcd..5e5ed8108498 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1441,6 +1441,30 @@ int xfrm_state_add(struct xfrm_state *x)
EXPORT_SYMBOL(xfrm_state_add);
#ifdef CONFIG_XFRM_MIGRATE
+static inline int clone_security(struct xfrm_state *x, struct xfrm_sec_ctx *security)
+{
+ struct xfrm_user_sec_ctx *uctx;
+ int size = sizeof(*uctx) + security->ctx_len;
+ int err;
+
+ uctx = kmalloc(size, GFP_KERNEL);
+ if (!uctx)
+ return -ENOMEM;
+
+ uctx->exttype = XFRMA_SEC_CTX;
+ uctx->len = size;
+ uctx->ctx_doi = security->ctx_doi;
+ uctx->ctx_alg = security->ctx_alg;
+ uctx->ctx_len = security->ctx_len;
+ memcpy(uctx + 1, security->ctx_str, security->ctx_len);
+ err = security_xfrm_state_alloc(x, uctx);
+ kfree(uctx);
+ if (err)
+ return err;
+
+ return 0;
+}
+
static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
struct xfrm_encap_tmpl *encap)
{
@@ -1497,6 +1521,10 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
goto error;
}
+ if (orig->security)
+ if (clone_security(x, orig->security))
+ goto error;
+
if (orig->coaddr) {
x->coaddr = kmemdup(orig->coaddr, sizeof(*x->coaddr),
GFP_KERNEL);
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 4/4] xfrm: clone whole liftime_cur structure in xfrm_do_migrate
2020-08-20 18:11 [PATCH 1/3] xfrm: clone XFRMA_SET_MARK during xfrm_do_migrate Antony Antony
` (9 preceding siblings ...)
2020-09-04 6:50 ` [PATCH v3 3/4] xfrm: clone XFRMA_SEC_CTX " Antony Antony
@ 2020-09-04 6:50 ` Antony Antony
10 siblings, 0 replies; 17+ messages in thread
From: Antony Antony @ 2020-09-04 6:50 UTC (permalink / raw)
To: Steffen Klassert, netdev, Herbert Xu; +Cc: Antony Antony, Antony Antony
When we clone state only add_time was cloned. It missed values like
bytes, packets. Now clone the all members of the structure.
v1->v3:
- use memcpy to copy the entire structure
Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
Signed-off-by: Antony Antony <antony.antony@secunet.com>
---
net/xfrm/xfrm_state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 5e5ed8108498..5ff392e6f3c1 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1550,7 +1550,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;
+ memcpy(&x->curlft, &orig->curlft, sizeof(x->curlft));
x->km.state = orig->km.state;
x->km.seq = orig->km.seq;
x->replay = orig->replay;
--
2.20.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/4] xfrm: clone XFRMA_SET_MARK in xfrm_do_migrate
2020-09-04 6:49 ` [PATCH v3 1/4] xfrm: clone XFRMA_SET_MARK " Antony Antony
@ 2020-09-09 5:54 ` Steffen Klassert
0 siblings, 0 replies; 17+ messages in thread
From: Steffen Klassert @ 2020-09-09 5:54 UTC (permalink / raw)
To: Antony Antony; +Cc: netdev, Herbert Xu, Antony Antony
On Fri, Sep 04, 2020 at 08:49:38AM +0200, Antony Antony wrote:
> XFRMA_SET_MARK and XFRMA_SET_MARK_MASK was not cloned from the old
> to the new. Migrate these two attributes during XFRMA_MSG_MIGRATE
>
> Fixes: 9b42c1f179a6 ("xfrm: Extend the output_mark to support input direction and masking.")
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
All applied, thanks Antony!
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2020-09-09 5:54 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v3 2/4] xfrm: clone XFRMA_REPLAY_ESN_VAL " Antony Antony
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
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).