Commit f2f20b3
mm: fix possible deadlock in kmemleak
commit c873ccb upstream.
There are some AA deadlock issues in kmemleak, similar to the situation
reported by Breno [1]. The deadlock path is as follows:
mem_pool_alloc()
-> raw_spin_lock_irqsave(&kmemleak_lock, flags);
-> pr_warn()
-> netconsole subsystem
-> netpoll
-> __alloc_skb
-> __create_object
-> raw_spin_lock_irqsave(&kmemleak_lock, flags);
To solve this problem, switch to printk_safe mode before printing warning
message, this will redirect all printk()-s to a special per-CPU buffer,
which will be flushed later from a safe context (irq work), and this
deadlock problem can be avoided. The proper API to use should be
printk_deferred_enter()/printk_deferred_exit() [2]. Another way is to
place the warn print after kmemleak is released.
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/all/[email protected]/#t [1]
Link: https://lore.kernel.org/all/[email protected]/ [2]
Signed-off-by: Gu Bowen <[email protected]>
Reviewed-by: Waiman Long <[email protected]>
Reviewed-by: Catalin Marinas <[email protected]>
Reviewed-by: Breno Leitao <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Lu Jialin <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit cd0236550cf80d47c8beeb2917a6aa7cf6a77b9a)1 parent a22ef60 commit f2f20b3
1 file changed
+20
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
435 | 440 | | |
436 | 441 | | |
437 | 442 | | |
| 443 | + | |
438 | 444 | | |
439 | 445 | | |
440 | 446 | | |
| |||
731 | 737 | | |
732 | 738 | | |
733 | 739 | | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
734 | 745 | | |
735 | 746 | | |
736 | 747 | | |
737 | 748 | | |
738 | 749 | | |
739 | 750 | | |
740 | 751 | | |
| 752 | + | |
741 | 753 | | |
742 | 754 | | |
743 | 755 | | |
| |||
851 | 863 | | |
852 | 864 | | |
853 | 865 | | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
| 866 | + | |
859 | 867 | | |
860 | | - | |
861 | 868 | | |
862 | 869 | | |
863 | 870 | | |
| |||
877 | 884 | | |
878 | 885 | | |
879 | 886 | | |
880 | | - | |
| 887 | + | |
881 | 888 | | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
882 | 895 | | |
883 | 896 | | |
884 | 897 | | |
| |||
0 commit comments