]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: reject loops from set element jump to chain
authorPablo Neira Ayuso <pablo@netfilter.org>
Sat, 11 Jun 2016 04:20:27 +0000 (12:20 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 15 Jun 2016 10:17:23 +0000 (12:17 +0200)
commit36786b41eaf59527545f5a78e2e632dda3f740a4
tree3b32986c8d5553fbb2a679b9a2e7fa57de79b8bd
parent62dcb553190d0ba8d6ec60ccfee13fb9603be428
netfilter: nf_tables: reject loops from set element jump to chain

Liping Zhang says:

"Users may add such a wrong nft rules successfully, which will cause an
endless jump loop:

  # nft add rule filter test tcp dport vmap {1: jump test}

This is because before we commit, the element in the current anonymous
set is inactive, so osp->walk will skip this element and miss the
validate check."

To resolve this problem, this patch passes the generation mask to the
walk function through the iter container structure depending on the code
path:

1) If we're dumping the elements, then we have to check if the element
   is active in the current generation. Thus, we check for the current
   bit in the genmask.

2) If we're checking for loops, then we have to check if the element is
   active in the next generation, as we're in the middle of a
   transaction. Thus, we check for the next bit in the genmask.

Based on original patch from Liping Zhang.

Reported-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Liping Zhang <liping.zhang@spreadtrum.com>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c
net/netfilter/nft_hash.c
net/netfilter/nft_rbtree.c