Commit 77a06c3
committed
eventfs: Test for ei->is_freed when accessing ei->dentry
The eventfs_inode (ei) is protected by SRCU, but the ei->dentry is not. It
is protected by the eventfs_mutex. Anytime the eventfs_mutex is released,
and access to the ei->dentry needs to be done, it should first check if
ei->is_freed is set under the eventfs_mutex. If it is, then the ei->dentry
is invalid and must not be used. The ei->dentry must only be accessed
under the eventfs_mutex and after checking if ei->is_freed is set.
When the ei is being freed, it will (under the eventfs_mutex) set is_freed
and at the same time move the dentry to a free list to be cleared after
the eventfs_mutex is released. This means that any access to the
ei->dentry must check first if ei->is_freed is set, because if it is, then
the dentry is on its way to be freed.
Also add comments to describe this better.
Link: https://lore.kernel.org/all/CA+G9fYt6pY+tMZEOg=SoEywQOe19fGP3uR15SGowkdK+_X85Cg@mail.gmail.com/
Link: https://lore.kernel.org/all/CA+G9fYuDP3hVQ3t7FfrBAjd_WFVSurMgCepTxunSJf=MTe=6aA@mail.gmail.com/
Link: https://lkml.kernel.org/r/20231101172649.477608228@goodmis.org
Cc: Ajay Kaher <akaher@vmware.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Fixes: 5790b1f ("eventfs: Remove eventfs_file and just use eventfs_inode")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reported-by: Beau Belgrave <beaub@linux.microsoft.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Beau Belgrave <beaub@linux.microsoft.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>1 parent db3a397 commit 77a06c3
2 files changed
Lines changed: 41 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
28 | 41 | | |
29 | 42 | | |
30 | 43 | | |
| |||
239 | 252 | | |
240 | 253 | | |
241 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
242 | 259 | | |
243 | 260 | | |
244 | 261 | | |
| |||
312 | 329 | | |
313 | 330 | | |
314 | 331 | | |
| 332 | + | |
| 333 | + | |
315 | 334 | | |
316 | 335 | | |
317 | 336 | | |
| |||
325 | 344 | | |
326 | 345 | | |
327 | 346 | | |
| 347 | + | |
328 | 348 | | |
329 | 349 | | |
330 | 350 | | |
331 | 351 | | |
332 | 352 | | |
333 | 353 | | |
334 | 354 | | |
335 | | - | |
| 355 | + | |
| 356 | + | |
336 | 357 | | |
337 | 358 | | |
338 | 359 | | |
339 | 360 | | |
340 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
341 | 366 | | |
342 | 367 | | |
343 | 368 | | |
| |||
440 | 465 | | |
441 | 466 | | |
442 | 467 | | |
443 | | - | |
| 468 | + | |
444 | 469 | | |
445 | 470 | | |
446 | 471 | | |
| |||
454 | 479 | | |
455 | 480 | | |
456 | 481 | | |
457 | | - | |
| 482 | + | |
458 | 483 | | |
459 | 484 | | |
460 | 485 | | |
| |||
588 | 613 | | |
589 | 614 | | |
590 | 615 | | |
591 | | - | |
| 616 | + | |
592 | 617 | | |
593 | 618 | | |
594 | 619 | | |
| |||
705 | 730 | | |
706 | 731 | | |
707 | 732 | | |
| 733 | + | |
708 | 734 | | |
709 | 735 | | |
710 | | - | |
711 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
712 | 740 | | |
713 | 741 | | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
714 | 747 | | |
715 | 748 | | |
716 | 749 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
0 commit comments