Skip to contentSkip to conversation

netfilter: nft_byteorder: length must be multiple of size

PATCH New Pablo Neira Ayuso 1 participant 1 message Feb 2, 2024

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nft_byteorder: length must be multiple of size

Although init path validates that store does not go over the register boundaries, the eval loop iterates over length / size to perform the byteorder swap.

Make sure length is a multiple of size, otherwise userspace is buggy.

Fixes 96518518cc41 ("netfilter: add nftables")
---
 net/netfilter/nft_byteorder.c | 3 +++
 1 file changed, 3 insertions(+)
net/netfilter/nft_byteorder.c +3 -0
index f6e791a68101..8cf91e47fd7a 100644
@@ -139,6 +139,9 @@ static int nft_byteorder_init(const struct nft_ctx *ctx,
 
 	priv->len = len;
 
+	if (len % size != 0)
+		return -EINVAL;
+
 	err = nft_parse_register_load(tb[NFTA_BYTEORDER_SREG], &priv->sreg,
 				      priv->len);
 	if (err < 0)
Signature · 1 line
2.30.2