Commit 723bfd6
committed
netfilter: nf_tables: do not defer rule destruction via call_rcu
JIRA: https://issues.redhat.com/browse/RHEL-68691
Upstream Status: commit b04df3d
commit b04df3d
Author: Florian Westphal <fw@strlen.de>
Date: Sat Dec 7 12:14:48 2024 +0100
netfilter: nf_tables: do not defer rule destruction via call_rcu
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: syzbot+b26935466701e56cfdc2@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/67478d92.050a0220.253251.0062.GAE@google.com/T/
Fixes: c03d278 ("netfilter: nf_tables: wait for rcu grace period on net_device removal")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fwestpha@redhat.com>1 parent cbf4d06 commit 723bfd6
File tree
2 files changed
+15
-21
lines changed- include/net/netfilter
- net/netfilter
2 files changed
+15
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1103 | 1103 | | |
1104 | 1104 | | |
1105 | 1105 | | |
1106 | | - | |
1107 | 1106 | | |
1108 | 1107 | | |
1109 | 1108 | | |
| |||
1121 | 1120 | | |
1122 | 1121 | | |
1123 | 1122 | | |
1124 | | - | |
1125 | 1123 | | |
1126 | 1124 | | |
1127 | 1125 | | |
| |||
1265 | 1263 | | |
1266 | 1264 | | |
1267 | 1265 | | |
1268 | | - | |
1269 | 1266 | | |
1270 | 1267 | | |
1271 | 1268 | | |
| |||
1285 | 1282 | | |
1286 | 1283 | | |
1287 | 1284 | | |
1288 | | - | |
1289 | 1285 | | |
1290 | 1286 | | |
1291 | 1287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1495 | 1495 | | |
1496 | 1496 | | |
1497 | 1497 | | |
1498 | | - | |
1499 | 1498 | | |
1500 | 1499 | | |
1501 | 1500 | | |
| |||
3869 | 3868 | | |
3870 | 3869 | | |
3871 | 3870 | | |
| 3871 | + | |
3872 | 3872 | | |
3873 | 3873 | | |
| 3874 | + | |
| 3875 | + | |
3874 | 3876 | | |
3875 | 3877 | | |
3876 | 3878 | | |
| |||
5635 | 5637 | | |
5636 | 5638 | | |
5637 | 5639 | | |
| 5640 | + | |
| 5641 | + | |
5638 | 5642 | | |
5639 | 5643 | | |
5640 | 5644 | | |
| |||
11442 | 11446 | | |
11443 | 11447 | | |
11444 | 11448 | | |
11445 | | - | |
11446 | | - | |
11447 | | - | |
11448 | | - | |
11449 | | - | |
11450 | | - | |
11451 | | - | |
11452 | | - | |
11453 | | - | |
11454 | | - | |
11455 | | - | |
11456 | | - | |
11457 | | - | |
11458 | 11449 | | |
11459 | 11450 | | |
11460 | 11451 | | |
| |||
11469 | 11460 | | |
11470 | 11461 | | |
11471 | 11462 | | |
11472 | | - | |
11473 | | - | |
11474 | | - | |
| 11463 | + | |
11475 | 11464 | | |
| 11465 | + | |
| 11466 | + | |
| 11467 | + | |
| 11468 | + | |
| 11469 | + | |
| 11470 | + | |
| 11471 | + | |
11476 | 11472 | | |
| 11473 | + | |
| 11474 | + | |
11477 | 11475 | | |
11478 | 11476 | | |
11479 | 11477 | | |
| |||
0 commit comments