Commit 4c05ec4
netfilter: nf_tables: fix suspicious RCU usage in nft_chain_stats_replace()
basechain->stats is rcu protected data which is updated from
nft_chain_stats_replace(). This function is executed from the commit
phase which holds the pernet nf_tables commit mutex - not the global
nfnetlink subsystem mutex.
Test commands to reproduce the problem are:
%iptables-nft -I INPUT
%iptables-nft -Z
%iptables-nft -Z
This patch uses RCU calls to handle basechain->stats updates to fix a
splat that looks like:
[89279.358755] =============================
[89279.363656] WARNING: suspicious RCU usage
[89279.368458] 4.20.0-rc2+ #44 Tainted: G W L
[89279.374661] -----------------------------
[89279.379542] net/netfilter/nf_tables_api.c:1404 suspicious rcu_dereference_protected() usage!
[...]
[89279.406556] 1 lock held by iptables-nft/5225:
[89279.411728] #0: 00000000bf45a000 (&net->nft.commit_mutex){+.+.}, at: nf_tables_valid_genid+0x1f/0x70 [nf_tables]
[89279.424022] stack backtrace:
[89279.429236] CPU: 0 PID: 5225 Comm: iptables-nft Tainted: G W L 4.20.0-rc2+ #44
[89279.430135] Call Trace:
[89279.430135] dump_stack+0xc9/0x16b
[89279.430135] ? show_regs_print_info+0x5/0x5
[89279.430135] ? lockdep_rcu_suspicious+0x117/0x160
[89279.430135] nft_chain_commit_update+0x4ea/0x640 [nf_tables]
[89279.430135] ? sched_clock_local+0xd4/0x140
[89279.430135] ? check_flags.part.35+0x440/0x440
[89279.430135] ? __rhashtable_remove_fast.constprop.67+0xec0/0xec0 [nf_tables]
[89279.430135] ? sched_clock_cpu+0x126/0x170
[89279.430135] ? find_held_lock+0x39/0x1c0
[89279.430135] ? hlock_class+0x140/0x140
[89279.430135] ? is_bpf_text_address+0x5/0xf0
[89279.430135] ? check_flags.part.35+0x440/0x440
[89279.430135] ? __lock_is_held+0xb4/0x140
[89279.430135] nf_tables_commit+0x2555/0x39c0 [nf_tables]
Fixes: f102d66 ("netfilter: nf_tables: use dedicated mutex to guard transactions")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>1 parent 986103e commit 4c05ec4
File tree
3 files changed
+14
-21
lines changed- include/linux/netfilter
- net/netfilter
3 files changed
+14
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 65 | | |
78 | 66 | | |
79 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1216 | 1216 | | |
1217 | 1217 | | |
1218 | 1218 | | |
1219 | | - | |
| 1219 | + | |
| 1220 | + | |
1220 | 1221 | | |
1221 | 1222 | | |
1222 | 1223 | | |
| |||
1392 | 1393 | | |
1393 | 1394 | | |
1394 | 1395 | | |
1395 | | - | |
| 1396 | + | |
| 1397 | + | |
1396 | 1398 | | |
1397 | 1399 | | |
1398 | 1400 | | |
1399 | 1401 | | |
1400 | 1402 | | |
1401 | 1403 | | |
1402 | 1404 | | |
1403 | | - | |
1404 | | - | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1405 | 1408 | | |
1406 | 1409 | | |
1407 | 1410 | | |
| |||
1439 | 1442 | | |
1440 | 1443 | | |
1441 | 1444 | | |
1442 | | - | |
1443 | | - | |
| 1445 | + | |
1444 | 1446 | | |
| 1447 | + | |
| 1448 | + | |
1445 | 1449 | | |
1446 | 1450 | | |
1447 | 1451 | | |
| |||
1590 | 1594 | | |
1591 | 1595 | | |
1592 | 1596 | | |
1593 | | - | |
| 1597 | + | |
1594 | 1598 | | |
1595 | 1599 | | |
1596 | 1600 | | |
| |||
6180 | 6184 | | |
6181 | 6185 | | |
6182 | 6186 | | |
6183 | | - | |
| 6187 | + | |
| 6188 | + | |
6184 | 6189 | | |
6185 | 6190 | | |
6186 | 6191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
0 commit comments