Commit 6013202
committed
lltable: Fix use-after-free race in llentry_free()
When callout_stop() returns 0, the timer callback is currently executing
on another CPU. The original code proceeded to free the llentry anyway,
causing a use-after-free when the timer callback (e.g., arptimer) accessed
the freed memory.
Fix by checking the callout_stop() return value:
- If >0: timer was pending and successfully cancelled, drop timer's ref
- If 0 and refcnt>1: another thread racing with timer, drop ref and bail;
timer's llentry_free() will free the entry
- If 0 and refcnt==1: we ARE the timer, proceed to free
- If <0: timer was not scheduled, proceed normally
PR: 285813
Signed-off-by: Teddy Engel <engel.teddy@gmail.com>1 parent 8dad295 commit 6013202
1 file changed
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
| 652 | + | |
652 | 653 | | |
653 | 654 | | |
654 | 655 | | |
655 | 656 | | |
656 | 657 | | |
657 | 658 | | |
658 | 659 | | |
659 | | - | |
660 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
661 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
662 | 684 | | |
663 | 685 | | |
664 | 686 | | |
| |||
0 commit comments