You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[XFRM]: xfrm_algo_clone() allocates too much memory
alg_key_len is the length in bits of the key, not in bytes. Best way to fix this is to move alg_len() function from net/xfrm/xfrm_user.c to include/net/xfrm.h, and to use it in xfrm_algo_clone() alg_len() is renamed to xfrm_alg_len() because of its global exposition. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
2e3884b5b1
commit
0f99be0d11
+6
-1
@@ -1188,10 +1188,15 @@ static inline int xfrm_aevent_is_on(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int xfrm_alg_len(struct xfrm_algo *alg)
|
||||
{
|
||||
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_XFRM_MIGRATE
|
||||
static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
|
||||
{
|
||||
return (struct xfrm_algo *)kmemdup(orig, sizeof(*orig) + orig->alg_key_len, GFP_KERNEL);
|
||||
return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
|
||||
}
|
||||
|
||||
static inline void xfrm_states_put(struct xfrm_state **states, int n)
|
||||
|
||||
Reference in New Issue
Block a user