Commit b0f013b
netfilter: nf_tables: do not defer rule destruction via call_rcu
commit b04df3da1b5c6f6dc7cdccc37941740c078c4043 upstream.
nf_tables_chain_destroy can sleep, it can't be used from call_rcu
callbacks.
Moreover, nf_tables_rule_release() is only safe for error unwinding,
while transaction mutex is held and the to-be-desroyed rule was not
exposed to either dataplane or dumps, as it deactives+frees without
the required synchronize_rcu() in-between.
nft_rule_expr_deactivate() callbacks will change ->use counters
of other chains/sets, see e.g. nft_lookup .deactivate callback, these
must be serialized via transaction mutex.
Also add a few lockdep asserts to make this more explicit.
Calling synchronize_rcu() isn't ideal, but fixing this without is hard
and way more intrusive. As-is, we can get:
WARNING: .. net/netfilter/nf_tables_api.c:5515 nft_set_destroy+0x..
Workqueue: events nf_tables_trans_destroy_work
RIP: 0010:nft_set_destroy+0x3fe/0x5c0
Call Trace:
<TASK>
nf_tables_trans_destroy_work+0x6b7/0xad0
process_one_work+0x64a/0xce0
worker_thread+0x613/0x10d0
In case the synchronize_rcu becomes an issue, we can explore alternatives.
One way would be to allocate nft_trans_rule objects + one nft_trans_chain
object, deactivate the rules + the chain and then defer the freeing to the
nft destroy workqueue. We'd still need to keep the synchronize_rcu path as
a fallback to handle -ENOMEM corner cases though.
Reported-by: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/T/
Fixes: c03d278fdf35 ("netfilter: nf_tables: wait for rcu grace period on net_device removal")
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent e6c32a6 commit b0f013b
File tree
2 files changed
+15
-20
lines changed- include/net/netfilter
- net/netfilter
2 files changed
+15
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1062 | 1062 | | |
1063 | 1063 | | |
1064 | 1064 | | |
1065 | | - | |
1066 | 1065 | | |
1067 | 1066 | | |
1068 | 1067 | | |
| |||
1205 | 1204 | | |
1206 | 1205 | | |
1207 | 1206 | | |
1208 | | - | |
1209 | 1207 | | |
1210 | 1208 | | |
1211 | 1209 | | |
| |||
1221 | 1219 | | |
1222 | 1220 | | |
1223 | 1221 | | |
1224 | | - | |
1225 | 1222 | | |
1226 | 1223 | | |
1227 | 1224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
1416 | | - | |
1417 | 1416 | | |
1418 | 1417 | | |
1419 | 1418 | | |
| |||
3511 | 3510 | | |
3512 | 3511 | | |
3513 | 3512 | | |
| 3513 | + | |
3514 | 3514 | | |
3515 | 3515 | | |
| 3516 | + | |
| 3517 | + | |
3516 | 3518 | | |
3517 | 3519 | | |
3518 | 3520 | | |
| |||
5248 | 5250 | | |
5249 | 5251 | | |
5250 | 5252 | | |
| 5253 | + | |
| 5254 | + | |
5251 | 5255 | | |
5252 | 5256 | | |
5253 | 5257 | | |
| |||
10674 | 10678 | | |
10675 | 10679 | | |
10676 | 10680 | | |
10677 | | - | |
10678 | | - | |
10679 | | - | |
10680 | | - | |
10681 | | - | |
10682 | | - | |
10683 | | - | |
10684 | | - | |
10685 | | - | |
10686 | | - | |
10687 | | - | |
10688 | | - | |
10689 | | - | |
10690 | 10681 | | |
10691 | 10682 | | |
10692 | 10683 | | |
| |||
10701 | 10692 | | |
10702 | 10693 | | |
10703 | 10694 | | |
10704 | | - | |
10705 | | - | |
10706 | | - | |
| 10695 | + | |
10707 | 10696 | | |
| 10697 | + | |
| 10698 | + | |
| 10699 | + | |
| 10700 | + | |
| 10701 | + | |
| 10702 | + | |
| 10703 | + | |
10708 | 10704 | | |
| 10705 | + | |
| 10706 | + | |
10709 | 10707 | | |
10710 | 10708 | | |
10711 | 10709 | | |
| |||
0 commit comments