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 authored and Steffen Klassert committed 2026-05-14 10:24:10 +02:00
1 parent a77d172177
commit 41c4d3b26f
1 file changed
+7 -1
+7 -1
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);