Byte-rate limits using long time units (e.g. bytes/week) can overflow priv->nsecs * skb->len in the packet-path cost calculation, silently defeating the configured rate limit. Reject such configurations at rule-add time instead, using the GRO maximum packet size as a conservative bound on skb length for the multiplication check. Fixes: d2168e849ebf ("netfilter: nft_limit: add per-byte limiting") Signed-off-by: SaifAllah benMassaoud --- net/netfilter/nft_limit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/netfilter/nft_limit.c b/net/netfilter/nft_limit.c index 167d99b1447f..07dc5c55b0a0 100644 --- a/net/netfilter/nft_limit.c +++ b/net/netfilter/nft_limit.c @@ -13,6 +13,7 @@ #include #include #include +#include struct nft_limit { spinlock_t lock; @@ -73,6 +74,9 @@ static int nft_limit_init(struct nft_limit_priv *priv, if (check_mul_overflow(unit, NSEC_PER_SEC, &priv->nsecs)) return -EOVERFLOW; + if (!pkts && priv->nsecs > U64_MAX / GRO_MAX_SIZE) + return -EOVERFLOW; + if (tb[NFTA_LIMIT_BURST]) priv->burst = ntohl(nla_get_be32(tb[NFTA_LIMIT_BURST])); base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b -- 2.53.0