]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
netfilter: nft_hash: validate maximum value of u32 netlink hash attribute
authorLaura Garcia Liebana <nevola@gmail.com>
Mon, 14 Nov 2016 21:33:34 +0000 (22:33 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Nov 2016 13:40:03 +0000 (14:40 +0100)
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").

Fixes: cb1b69b0b15b ("netfilter: nf_tables: add hash expression")
Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_hash.c

index baf694de3935a29561d513a56dbd3c8f8690e196..d5447a22275c0649cb125364730986a52436816d 100644 (file)
@@ -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] ||
@@ -67,8 +68,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;