mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-12 23:38:28 +07:00
xfrm: Clone states properly on migration
We loose a lot of information of the original state if we clone it with xfrm_state_clone(). In particular, there is no crypto algorithm attached if the original state uses an aead algorithm. This patch add the missing information to the clone state. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
parent
8c0cba22e1
commit
ee5c23176f
@ -1648,6 +1648,11 @@ static inline int xfrm_aevent_is_on(struct net *net)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline int aead_len(struct xfrm_algo_aead *alg)
|
||||||
|
{
|
||||||
|
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int xfrm_alg_len(const struct xfrm_algo *alg)
|
static inline int xfrm_alg_len(const struct xfrm_algo *alg)
|
||||||
{
|
{
|
||||||
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
|
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
|
||||||
@ -1686,6 +1691,12 @@ static inline int xfrm_replay_clone(struct xfrm_state *x,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct xfrm_algo_aead *xfrm_algo_aead_clone(struct xfrm_algo_aead *orig)
|
||||||
|
{
|
||||||
|
return kmemdup(orig, aead_len(orig), GFP_KERNEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
|
static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
|
||||||
{
|
{
|
||||||
return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
|
return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
|
||||||
|
@ -1159,6 +1159,11 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
|
|||||||
}
|
}
|
||||||
x->props.aalgo = orig->props.aalgo;
|
x->props.aalgo = orig->props.aalgo;
|
||||||
|
|
||||||
|
if (orig->aead) {
|
||||||
|
x->aead = xfrm_algo_aead_clone(orig->aead);
|
||||||
|
if (!x->aead)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
if (orig->ealg) {
|
if (orig->ealg) {
|
||||||
x->ealg = xfrm_algo_clone(orig->ealg);
|
x->ealg = xfrm_algo_clone(orig->ealg);
|
||||||
if (!x->ealg)
|
if (!x->ealg)
|
||||||
@ -1201,6 +1206,9 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
|
|||||||
x->props.flags = orig->props.flags;
|
x->props.flags = orig->props.flags;
|
||||||
x->props.extra_flags = orig->props.extra_flags;
|
x->props.extra_flags = orig->props.extra_flags;
|
||||||
|
|
||||||
|
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.add_time = orig->curlft.add_time;
|
||||||
x->km.state = orig->km.state;
|
x->km.state = orig->km.state;
|
||||||
x->km.seq = orig->km.seq;
|
x->km.seq = orig->km.seq;
|
||||||
|
@ -32,11 +32,6 @@
|
|||||||
#include <linux/in6.h>
|
#include <linux/in6.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int aead_len(struct xfrm_algo_aead *alg)
|
|
||||||
{
|
|
||||||
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
|
static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
|
||||||
{
|
{
|
||||||
struct nlattr *rt = attrs[type];
|
struct nlattr *rt = attrs[type];
|
||||||
|
Loading…
Reference in New Issue
Block a user