Commit 2991dc3
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 558f503 commit 2991dc3
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 | |
|---|---|---|---|
| |||
962 | 962 | | |
963 | 963 | | |
964 | 964 | | |
965 | | - | |
966 | 965 | | |
967 | 966 | | |
968 | 967 | | |
| |||
1101 | 1100 | | |
1102 | 1101 | | |
1103 | 1102 | | |
1104 | | - | |
1105 | 1103 | | |
1106 | 1104 | | |
1107 | 1105 | | |
| |||
1117 | 1115 | | |
1118 | 1116 | | |
1119 | 1117 | | |
1120 | | - | |
1121 | 1118 | | |
1122 | 1119 | | |
1123 | 1120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
1302 | | - | |
1303 | 1302 | | |
1304 | 1303 | | |
1305 | 1304 | | |
| |||
3345 | 3344 | | |
3346 | 3345 | | |
3347 | 3346 | | |
| 3347 | + | |
3348 | 3348 | | |
3349 | 3349 | | |
| 3350 | + | |
| 3351 | + | |
3350 | 3352 | | |
3351 | 3353 | | |
3352 | 3354 | | |
| |||
4858 | 4860 | | |
4859 | 4861 | | |
4860 | 4862 | | |
| 4863 | + | |
| 4864 | + | |
4861 | 4865 | | |
4862 | 4866 | | |
4863 | 4867 | | |
| |||
9571 | 9575 | | |
9572 | 9576 | | |
9573 | 9577 | | |
9574 | | - | |
9575 | | - | |
9576 | | - | |
9577 | | - | |
9578 | | - | |
9579 | | - | |
9580 | | - | |
9581 | | - | |
9582 | | - | |
9583 | | - | |
9584 | | - | |
9585 | | - | |
9586 | | - | |
9587 | 9578 | | |
9588 | 9579 | | |
9589 | 9580 | | |
| |||
9598 | 9589 | | |
9599 | 9590 | | |
9600 | 9591 | | |
9601 | | - | |
9602 | | - | |
9603 | | - | |
| 9592 | + | |
9604 | 9593 | | |
| 9594 | + | |
| 9595 | + | |
| 9596 | + | |
| 9597 | + | |
| 9598 | + | |
| 9599 | + | |
| 9600 | + | |
9605 | 9601 | | |
| 9602 | + | |
| 9603 | + | |
9606 | 9604 | | |
9607 | 9605 | | |
9608 | 9606 | | |
| |||
0 commit comments