Skip to contentSkip to conversation

xfrm: Reject excessive values for XFRMA_TFCPAD

PATCH In review David Ahern 2 participants 2 messages May 13 – May 16

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: Reject excessive values for XFRMA_TFCPAD

From: David Ahern <[email protected]>

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

---
 net/xfrm/xfrm_user.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +7 -1
index 38a90e5ee3d9..e8c31633f4f1 100644
@@ -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);
 
Signature · 1 line
2.43.0