Skip to contentSkip to conversation

netfilter: nft_hash: fix hash overflow validation

PATCH Applied Laura Garcia Liebana 2 participants 2 messages Sep 13, 2016

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

PATCH 1/1 netfilter: nft_hash: fix hash overflow validation

The overflow validation in the init() function establishes that the maximum value that the hash could reach is less than U32_MAX, which is likely to be true.

The fix detects the overflow when the maximum hash value is less than the offset itself.

Fixes 70ca767ea1b2 ("netfilter: nft_hash: Add hash offset value")
---
 net/netfilter/nft_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_hash.c +1 -1
index bd12f7a..09473b4 100644
@@ -76,7 +76,7 @@ static int nft_hash_init(const struct nft_ctx *ctx,
 	if (priv->modulus <= 1)
 		return -ERANGE;
 
-	if (priv->offset + priv->modulus - 1 < U32_MAX)
+	if (priv->offset + priv->modulus - 1 < priv->offset)
 		return -EOVERFLOW;
 
 	priv->seed = ntohl(nla_get_be32(tb[NFTA_HASH_SEED]));
Signature · 1 line
2.8.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Laura Garcia Liebana

The overflow validation in the init() function establishes that the maximum value that the hash could reach is less than U32_MAX, which is likely to be true.

The fix detects the overflow when the maximum hash value is less than the offset itself.

Applied.