Commit 9c29a2f
neighbor: Fix locking order for gc_list changes
Lock checker noted an inverted lock order between neigh_change_state
(neighbor lock then table lock) and neigh_periodic_work (table lock and
then neighbor lock) resulting in:
[ 121.057652] ======================================================
[ 121.058740] WARNING: possible circular locking dependency detected
[ 121.059861] 4.20.0-rc6+ #43 Not tainted
[ 121.060546] ------------------------------------------------------
[ 121.061630] kworker/0:2/65 is trying to acquire lock:
[ 121.062519] (____ptrval____) (&n->lock){++--}, at: neigh_periodic_work+0x237/0x324
[ 121.063894]
[ 121.063894] but task is already holding lock:
[ 121.064920] (____ptrval____) (&tbl->lock){+.-.}, at: neigh_periodic_work+0x194/0x324
[ 121.066274]
[ 121.066274] which lock already depends on the new lock.
[ 121.066274]
[ 121.067693]
[ 121.067693] the existing dependency chain (in reverse order) is:
...
Fix by renaming neigh_change_state to neigh_update_gc_list, changing
it to only manage whether an entry should be on the gc_list and taking
locks in the same order as neigh_periodic_work. Invoke at the end of
neigh_update only if diff between old or new states has the PERMANENT
flag set.
Fixes: 8cc196d ("neighbor: gc_list changes should be protected by table lock")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent aeb3fec commit 9c29a2f
1 file changed
+15
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
134 | 133 | | |
135 | | - | |
| 134 | + | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
140 | 143 | | |
141 | | - | |
142 | 144 | | |
143 | | - | |
144 | | - | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | 148 | | |
150 | | - | |
151 | | - | |
152 | 149 | | |
153 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
1220 | 1220 | | |
1221 | 1221 | | |
1222 | 1222 | | |
1223 | | - | |
| 1223 | + | |
1224 | 1224 | | |
1225 | 1225 | | |
1226 | 1226 | | |
| |||
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
1302 | | - | |
| 1302 | + | |
1303 | 1303 | | |
1304 | 1304 | | |
1305 | 1305 | | |
| |||
1360 | 1360 | | |
1361 | 1361 | | |
1362 | 1362 | | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
1363 | 1366 | | |
1364 | 1367 | | |
1365 | 1368 | | |
| |||
0 commit comments