netfilter: nf_tables: fix racy rule deletion
We may lost race if we flush the rule-set (which happens asynchronously via call_rcu) and we try to remove the table (that userspace assumes to be empty). Fix this by recovering synchronous rule and chain deletion. This was introduced time ago before we had no batch support, and synchronous rule deletion performance was not good. Now that we have the batch support, we can just postpone the purge of old rule in a second step in the commit phase. All object deletions are synchronous after this patch. As a side effect, we save memory as we don't need rcu_head per rule anymore. Cc: Patrick McHardy <kaber@trash.net> Reported-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
@@ -322,7 +322,6 @@ static inline void *nft_expr_priv(const struct nft_expr *expr)
|
||||
* struct nft_rule - nf_tables rule
|
||||
*
|
||||
* @list: used internally
|
||||
* @rcu_head: used internally for rcu
|
||||
* @handle: rule handle
|
||||
* @genmask: generation mask
|
||||
* @dlen: length of expression data
|
||||
@@ -330,7 +329,6 @@ static inline void *nft_expr_priv(const struct nft_expr *expr)
|
||||
*/
|
||||
struct nft_rule {
|
||||
struct list_head list;
|
||||
struct rcu_head rcu_head;
|
||||
u64 handle:46,
|
||||
genmask:2,
|
||||
dlen:16;
|
||||
@@ -391,7 +389,6 @@ enum nft_chain_flags {
|
||||
*
|
||||
* @rules: list of rules in the chain
|
||||
* @list: used internally
|
||||
* @rcu_head: used internally
|
||||
* @net: net namespace that this chain belongs to
|
||||
* @table: table that this chain belongs to
|
||||
* @handle: chain handle
|
||||
@@ -403,7 +400,6 @@ enum nft_chain_flags {
|
||||
struct nft_chain {
|
||||
struct list_head rules;
|
||||
struct list_head list;
|
||||
struct rcu_head rcu_head;
|
||||
struct net *net;
|
||||
struct nft_table *table;
|
||||
u64 handle;
|
||||
|
||||
Reference in New Issue
Block a user