Commit 68aaee1
mm: memcontrol: fix potential oom_lock recursion deadlock
syzbot is reporting GFP_KERNEL allocation with oom_lock held when
reporting memcg OOM [1]. If this allocation triggers the global OOM
situation then the system can livelock because the GFP_KERNEL
allocation with oom_lock held cannot trigger the global OOM killer
because __alloc_pages_may_oom() fails to hold oom_lock.
Fix this problem by removing the allocation from memory_stat_format()
completely, and pass static buffer when calling from memcg OOM path.
Note that the caller holding filesystem lock was the trigger for syzbot
to report this locking dependency. Doing GFP_KERNEL allocation with
filesystem lock held can deadlock the system even without involving OOM
situation.
Link: https://syzkaller.appspot.com/bug?extid=2d2aeadc6ce1e1f11d45 [1]
Link: https://lkml.kernel.org/r/86afb39f-8c65-bec2-6cfc-c5e3cd600c0b@I-love.SAKURA.ne.jp
Fixes: c8713d0 ("mm: memcontrol: dump memory.stat during cgroup OOM")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+2d2aeadc6ce1e1f11d45@syzkaller.appspotmail.com>
Suggested-by: Michal Hocko <mhocko@suse.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 65974cb commit 68aaee1
1 file changed
Lines changed: 9 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1490 | 1490 | | |
1491 | 1491 | | |
1492 | 1492 | | |
1493 | | - | |
| 1493 | + | |
1494 | 1494 | | |
1495 | 1495 | | |
1496 | 1496 | | |
1497 | 1497 | | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
| 1498 | + | |
1501 | 1499 | | |
1502 | 1500 | | |
1503 | 1501 | | |
| |||
1539 | 1537 | | |
1540 | 1538 | | |
1541 | 1539 | | |
1542 | | - | |
1543 | | - | |
1544 | 1540 | | |
1545 | 1541 | | |
1546 | 1542 | | |
| |||
1576 | 1572 | | |
1577 | 1573 | | |
1578 | 1574 | | |
1579 | | - | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
1580 | 1579 | | |
1581 | 1580 | | |
1582 | 1581 | | |
| |||
1597 | 1596 | | |
1598 | 1597 | | |
1599 | 1598 | | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
| 1599 | + | |
1603 | 1600 | | |
1604 | | - | |
1605 | 1601 | | |
1606 | 1602 | | |
1607 | 1603 | | |
| |||
6405 | 6401 | | |
6406 | 6402 | | |
6407 | 6403 | | |
6408 | | - | |
| 6404 | + | |
6409 | 6405 | | |
6410 | | - | |
6411 | 6406 | | |
6412 | 6407 | | |
| 6408 | + | |
6413 | 6409 | | |
6414 | 6410 | | |
6415 | 6411 | | |
| |||
0 commit comments