Skip to content

Commit fa6dd8a

Browse files
NicolasDichteldavem330
authored andcommitted
xfrm: check trunc_len in XFRMA_ALG_AUTH_TRUNC
Maximum trunc length is defined by MAX_AH_AUTH_LEN (in bytes) and need to be checked when this value is set (in bits) by the user. In ah4.c and ah6.c a BUG_ON() checks this condiftion. Signed-off-by: Nicolas Dichtel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f76957f commit fa6dd8a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/xfrm/xfrm_user.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <net/sock.h>
2727
#include <net/xfrm.h>
2828
#include <net/netlink.h>
29+
#include <net/ah.h>
2930
#include <asm/uaccess.h>
3031
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
3132
#include <linux/in6.h>
@@ -302,7 +303,8 @@ static int attach_auth_trunc(struct xfrm_algo_auth **algpp, u8 *props,
302303
algo = xfrm_aalg_get_byname(ualg->alg_name, 1);
303304
if (!algo)
304305
return -ENOSYS;
305-
if (ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits)
306+
if ((ualg->alg_trunc_len / 8) > MAX_AH_AUTH_LEN ||
307+
ualg->alg_trunc_len > algo->uinfo.auth.icv_fullbits)
306308
return -EINVAL;
307309
*props = algo->desc.sadb_alg_id;
308310

0 commit comments

Comments
 (0)