Repository navigation
Commit a2673b6
fsnotify: fix oops in fsnotify_clear_marks_by_group_flags()
fsnotify_clear_marks_by_group_flags() can race with
fsnotify_destroy_marks() so when fsnotify_destroy_mark_locked() drops
mark_mutex, a mark from the list iterated by
fsnotify_clear_marks_by_group_flags() can be freed and we dereference free
memory in the loop there.
Fix the problem by keeping mark_mutex held in
fsnotify_destroy_mark_locked(). The reason why we drop that mutex is that
we need to call a ->freeing_mark() callback which may acquire mark_mutex
again. To avoid this and similar lock inversion issues, we move the call
to ->freeing_mark() callback to the kthread destroying the mark.
Signed-off-by: Jan Kara <jack@suse.cz>
Reported-by: Ashish Sangwan <a.sangwan@samsung.com>
Suggested-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 3581d45 commit a2673b6
1 file changed
Lines changed: 14 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | 155 | | |
157 | 156 | | |
158 | 157 | | |
159 | 158 | | |
160 | | - | |
161 | | - | |
162 | 159 | | |
163 | 160 | | |
164 | 161 | | |
165 | 162 | | |
166 | 163 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 164 | | |
181 | 165 | | |
182 | 166 | | |
| |||
191 | 175 | | |
192 | 176 | | |
193 | 177 | | |
194 | | - | |
195 | | - | |
196 | 178 | | |
197 | 179 | | |
198 | 180 | | |
| |||
205 | 187 | | |
206 | 188 | | |
207 | 189 | | |
208 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
209 | 194 | | |
210 | 195 | | |
211 | 196 | | |
| |||
406 | 391 | | |
407 | 392 | | |
408 | 393 | | |
409 | | - | |
| 394 | + | |
410 | 395 | | |
411 | 396 | | |
412 | 397 | | |
| |||
460 | 445 | | |
461 | 446 | | |
462 | 447 | | |
| 448 | + | |
463 | 449 | | |
464 | 450 | | |
465 | 451 | | |
| |||
471 | 457 | | |
472 | 458 | | |
473 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
474 | 468 | | |
475 | 469 | | |
476 | 470 | | |
| |||
0 commit comments