Commit b04df3d
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>1 parent f36b019 commit b04df3d
2 files changed
Lines changed: 15 additions & 21 deletions
| 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 | |
|---|---|---|---|
| |||
1596 | 1596 | | |
1597 | 1597 | | |
1598 | 1598 | | |
1599 | | - | |
1600 | 1599 | | |
1601 | 1600 | | |
1602 | 1601 | | |
| |||
3987 | 3986 | | |
3988 | 3987 | | |
3989 | 3988 | | |
| 3989 | + | |
3990 | 3990 | | |
3991 | 3991 | | |
| 3992 | + | |
| 3993 | + | |
3992 | 3994 | | |
3993 | 3995 | | |
3994 | 3996 | | |
| |||
5757 | 5759 | | |
5758 | 5760 | | |
5759 | 5761 | | |
| 5762 | + | |
| 5763 | + | |
5760 | 5764 | | |
5761 | 5765 | | |
5762 | 5766 | | |
| |||
11695 | 11699 | | |
11696 | 11700 | | |
11697 | 11701 | | |
11698 | | - | |
11699 | | - | |
11700 | | - | |
11701 | | - | |
11702 | | - | |
11703 | | - | |
11704 | | - | |
11705 | | - | |
11706 | | - | |
11707 | | - | |
11708 | | - | |
11709 | | - | |
11710 | | - | |
11711 | 11702 | | |
11712 | 11703 | | |
11713 | 11704 | | |
| |||
11722 | 11713 | | |
11723 | 11714 | | |
11724 | 11715 | | |
11725 | | - | |
11726 | | - | |
11727 | | - | |
| 11716 | + | |
11728 | 11717 | | |
| 11718 | + | |
| 11719 | + | |
| 11720 | + | |
| 11721 | + | |
| 11722 | + | |
| 11723 | + | |
| 11724 | + | |
11729 | 11725 | | |
| 11726 | + | |
| 11727 | + | |
11730 | 11728 | | |
11731 | 11729 | | |
11732 | 11730 | | |
| |||
0 commit comments