Florian Westphal f32bb2aad2 netfilter: nf_tables: can't fail after linking rule into active rule list
commit 569ccae68b38654f04b6842b034aa33857f605fe upstream.

rules in nftables a free'd using kfree, but protected by rcu, i.e. we
must wait for a grace period to elapse.

Normal removal patch does this, but nf_tables_newrule() doesn't obey
this rule during error handling.

It calls nft_trans_rule_add() *after* linking rule, and, if that
fails to allocate memory, it unlinks the rule and then kfree() it --
this is unsafe.

Switch order -- first add rule to transaction list, THEN link it
to public list.

Note: nft_trans_rule_add() uses GFP_KERNEL; it will not fail so this
is not a problem in practice (spotted only during code review).

Fixes: 0628b123c96d12 ("netfilter: nfnetlink: add batch support and use it from nf_tables")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-22 16:57:57 +02:00
..
2018-05-16 10:08:44 +02:00
2016-12-03 23:54:25 -05:00
2018-05-19 10:26:57 +02:00
2017-11-15 15:53:17 +01:00
2018-04-13 19:48:29 +02:00
2018-05-19 10:26:59 +02:00
2018-05-19 10:26:57 +02:00
2016-10-20 11:23:08 -04:00
2018-04-20 08:21:07 +02:00
2018-04-24 09:34:17 +02:00
2016-08-17 19:36:23 -04:00
2016-08-17 19:36:23 -04:00