]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: fix set->nelems counting with no NLM_F_EXCL
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 23 Jan 2017 23:51:32 +0000 (00:51 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 24 Jan 2017 20:46:57 +0000 (21:46 +0100)
commit1f3f362bf2c305ffc36a6f8d439359fbb0da4732
tree7e0c00c119db64c093a68078be5a68e6d53275ec
parenta6c6784f0efff03177bda8d35267704a20561c58
netfilter: nf_tables: fix set->nelems counting with no NLM_F_EXCL

If the element exists and no NLM_F_EXCL is specified, do not bump
set->nelems, otherwise we leak one set element slot. This problem
amplifies if the set is full since the abort path always decrements the
counter for the -ENFILE case too, giving one spare extra slot.

Fix this by moving set->nelems update to nft_add_set_elem() after
successful element insertion. Moreover, remove the element if the set is
full so there is no need to rely on the abort path to undo things
anymore.

Fixes: e895e6d8850b ("netfilter: nf_tables: honor NLM_F_EXCL flag in set element insertion")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c