xfrm: Reject excessive values for XFRMA_TFCPAD

tfcpad is a u32, but that full range is excessive for padding.
Limit it to max IP length (64k).

Signed-off-by: David Ahern <dahern@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
David Ahern 2026-05-13 10:50:24 -06:00 committed by Steffen Klassert
parent a77d172177
commit 41c4d3b26f

View File

@ -937,8 +937,14 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
attrs[XFRMA_ALG_COMP], extack)))
goto error;
if (attrs[XFRMA_TFCPAD])
if (attrs[XFRMA_TFCPAD]) {
x->tfcpad = nla_get_u32(attrs[XFRMA_TFCPAD]);
if (x->tfcpad > IP_MAX_MTU) {
NL_SET_ERR_MSG(extack, "Excessive TFC padding");
err = -EINVAL;
goto error;
}
}
xfrm_mark_get(attrs, &x->mark);