Commit f886497
ipv4: fix dst race in sk_dst_get()
When IP route cache had been removed in linux-3.6, we broke assumption
that dst entries were all freed after rcu grace period. DST_NOCACHE
dst were supposed to be freed from dst_release(). But it appears
we want to keep such dst around, either in UDP sockets or tunnels.
In sk_dst_get() we need to make sure dst refcount is not 0
before incrementing it, or else we might end up freeing a dst
twice.
DST_NOCACHE set on a dst does not mean this dst can not be attached
to a socket or a tunnel.
Then, before actual freeing, we need to observe a rcu grace period
to make sure all other cpus can catch the fact the dst is no longer
usable.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dormando <dormando@rydia.net>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent 99e72a0 commit f886497
3 files changed
+18
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1730 | 1730 | | |
1731 | 1731 | | |
1732 | 1732 | | |
1733 | | - | |
1734 | | - | |
| 1733 | + | |
| 1734 | + | |
1735 | 1735 | | |
1736 | 1736 | | |
1737 | 1737 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
275 | 284 | | |
276 | 285 | | |
277 | 286 | | |
278 | 287 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 288 | + | |
| 289 | + | |
284 | 290 | | |
285 | 291 | | |
286 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 76 | + | |
82 | 77 | | |
83 | 78 | | |
84 | 79 | | |
| |||
108 | 103 | | |
109 | 104 | | |
110 | 105 | | |
| 106 | + | |
| 107 | + | |
111 | 108 | | |
112 | 109 | | |
113 | | - | |
114 | 110 | | |
115 | | - | |
| 111 | + | |
| 112 | + | |
116 | 113 | | |
117 | | - | |
118 | 114 | | |
119 | 115 | | |
120 | 116 | | |
| |||
0 commit comments