]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: don't skip inactive chains during update
authorFlorian Westphal <fw@strlen.de>
Wed, 31 Oct 2018 17:26:20 +0000 (18:26 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Nov 2018 15:13:35 +0000 (16:13 +0100)
commit095e44d83bbe279a4d69eb8423c6aaddaa120c0a
treea5bbef61262e9d4c83b5e80e3f0e43abbfd14a89
parentf7acd0d23bf2594f77483b0ce086a9cd8514e7d8
netfilter: nf_tables: don't skip inactive chains during update

There is no synchronization between packet path and the configuration plane.

The packet path uses two arrays with rules, one contains the current (active)
generation.  The other either contains the last (obsolete) generation or
the future one.

Consider:
cpu1               cpu2
                   nft_do_chain(c);
delete c
net->gen++;
                   genbit = !!net->gen;
                   rules = c->rg[genbit];

cpu1 ignores c when updating if c is not active anymore in the new
generation.

On cpu2, we now use rules from wrong generation, as c->rg[old]
contains the rules matching 'c' whereas c->rg[new] was not updated and
can even point to rules that have been free'd already, causing a crash.

To fix this, make sure that 'current' to the 'next' generation are
identical for chains that are going away so that c->rg[new] will just
use the matching rules even if genbit was incremented already.

Fixes: 82560e53d11eb ("netfilter: nf_tables: remove synchronize_rcu in commit phase")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c