Re: [PATCH net-next v2] net/sched: cls_flow: avoid integer overflow in perturb_period

From: Paolo Abeni

Date: Thu Nov 12 2026 - 08:44:46 EST


On 11/6/26 07:38, Wei Tao wrote:
@@ -486,7 +487,13 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
if (tb[TCA_FLOW_PERTURB]) {
if (mode != FLOW_MODE_HASH)
goto err2;
- perturb_period = nla_get_u32(tb[TCA_FLOW_PERTURB]) * HZ;
+ val = nla_get_u32(tb[TCA_FLOW_PERTURB]);
+ if (val > INT_MAX / HZ) {
+ NL_SET_ERR_MSG_MOD(extack, "invalid perturb period");
+ err = -EINVAL;
+ goto err2;

Sashiko noted the added code could by simplified/substituted with
a NLA_POLICY_FULL_RANGE(NLA_U32, &range):

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106063823.99731-1-taowei@xxxxxxxxxx

/P