netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next] netfilter: nf_tables: validate maximum value of u32 netlink hash attribute
@ 2016-11-14 21:33 Laura Garcia Liebana
  2016-11-24 13:43 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Laura Garcia Liebana @ 2016-11-14 21:33 UTC (permalink / raw)
  To: netfilter-devel

Use the function nft_parse_u32_check() to fetch the value and validate
the u32 attribute into the hash len u8 field.

This patch revisits 4da449ae1df9 ("netfilter: nft_exthdr: Add size check
on u8 nft_exthdr attributes").

Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
---
 net/netfilter/nft_hash.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c
index 97ad8e30e4b4..eb2721af898d 100644
--- a/net/netfilter/nft_hash.c
+++ b/net/netfilter/nft_hash.c
@@ -53,6 +53,7 @@ static int nft_hash_init(const struct nft_ctx *ctx,
 {
 	struct nft_hash *priv = nft_expr_priv(expr);
 	u32 len;
+	int err;
 
 	if (!tb[NFTA_HASH_SREG] ||
 	    !tb[NFTA_HASH_DREG] ||
@@ -66,8 +67,10 @@ static int nft_hash_init(const struct nft_ctx *ctx,
 	priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]);
 	priv->dreg = nft_parse_register(tb[NFTA_HASH_DREG]);
 
-	len = ntohl(nla_get_be32(tb[NFTA_HASH_LEN]));
-	if (len == 0 || len > U8_MAX)
+	err = nft_parse_u32_check(tb[NFTA_HASH_LEN], U8_MAX, &len);
+	if (err < 0)
+		return err;
+	if (len == 0)
 		return -ERANGE;
 
 	priv->len = len;
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nf-next] netfilter: nf_tables: validate maximum value of u32 netlink hash attribute
  2016-11-14 21:33 [PATCH nf-next] netfilter: nf_tables: validate maximum value of u32 netlink hash attribute Laura Garcia Liebana
@ 2016-11-24 13:43 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-11-24 13:43 UTC (permalink / raw)
  To: Laura Garcia Liebana; +Cc: netfilter-devel

On Mon, Nov 14, 2016 at 10:33:34PM +0100, Laura Garcia Liebana wrote:
> Use the function nft_parse_u32_check() to fetch the value and validate
> the u32 attribute into the hash len u8 field.
> 
> This patch revisits 4da449ae1df9 ("netfilter: nft_exthdr: Add size check
> on u8 nft_exthdr attributes").

Applied, thanks.

Please, always target your fixes to nf.

New features go to nf-next.

Regarding patch title, in second place we usually specify to what
component this is targeted to, so I would suggest:

  netfilter: nft_hash: validate maximum value of u32 netlink hash attribute

so git log --oneline quickly tells us this is targetd to nft_hash.

I have also added this tag which is useful for -stable maintainers:

Fixes: cb1b69b0b15b ("netfilter: nf_tables: add hash expression")

Thanks Laura!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-24 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-14 21:33 [PATCH nf-next] netfilter: nf_tables: validate maximum value of u32 netlink hash attribute Laura Garcia Liebana
2016-11-24 13:43 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).