netfilter: nf_tables: validate NFTA_SET_TABLE parameter
authorPhil Turnbull <phil.turnbull@oracle.com>
Fri, 27 May 2016 17:34:04 +0000 (13:34 -0400)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 30 May 2016 10:21:23 +0000 (12:21 +0200)
If the NFTA_SET_TABLE parameter is missing and the NLM_F_DUMP flag is
not set, then a NULL pointer dereference is triggered in
nf_tables_set_lookup because ctx.table is NULL.

Signed-off-by: Phil Turnbull <phil.turnbull@oracle.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index 2011977..6947e25 100644 (file)
@@ -2641,6 +2641,8 @@ static int nf_tables_getset(struct net *net, struct sock *nlsk,
        /* Only accept unspec with dump */
        if (nfmsg->nfgen_family == NFPROTO_UNSPEC)
                return -EAFNOSUPPORT;
+       if (!nla[NFTA_SET_TABLE])
+               return -EINVAL;
 
        set = nf_tables_set_lookup(ctx.table, nla[NFTA_SET_NAME]);
        if (IS_ERR(set))