From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm <linux-mm@kvack.org>
Subject: [PATCH] mm: memcontrol: fix potential oom_lock recursion deadlock
Date: Thu, 21 Jul 2022 08:49:57 +0900 [thread overview]
Message-ID: <a154df77-10c0-fa44-7471-9e73b6b52a72@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <03304bf8-d153-698f-0376-9e9a0ec1048e@I-love.SAKURA.ne.jp>
syzbot is reporting fs_reclaim allocation with oom_lock held [1]. We
must make sure that such allocation won't hit __alloc_pages_may_oom()
path which will retry forever if oom_lock is already held.
I choose GFP_ATOMIC than GFP_NOWAIT, for since global OOM situation will
likely be avoided by killing some process in memcg, and memory will be
released after printk(), trying a little hard will be acceptable.
Link: https://syzkaller.appspot.com/bug?extid=2d2aeadc6ce1e1f11d45 [1]
Reported-by: syzbot <syzbot+2d2aeadc6ce1e1f11d45@syzkaller.appspotmail.com>
Fixes: c8713d0b23123759 ("mm: memcontrol: dump memory.stat during cgroup OOM")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
mm/memcontrol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 618c366a2f07..11cd900729b9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1465,7 +1465,8 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
struct seq_buf s;
int i;
- seq_buf_init(&s, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE);
+ /* Caller might be holding oom_lock. */
+ seq_buf_init(&s, kmalloc(PAGE_SIZE, GFP_ATOMIC), PAGE_SIZE);
if (!s.buffer)
return NULL;
--
2.18.4
next prev parent reply other threads:[~2022-07-20 23:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <000000000000471c2905e3c2c2c2@google.com>
2022-07-14 14:18 ` [syzbot] possible deadlock in start_this_handle (3) Jan Kara
[not found] ` <534fa596-0c29-0f1e-b292-53ad9c3dbbe3@I-love.SAKURA.ne.jp>
2022-07-15 1:39 ` Shakeel Butt
[not found] ` <03304bf8-d153-698f-0376-9e9a0ec1048e@I-love.SAKURA.ne.jp>
2022-07-20 23:49 ` Tetsuo Handa [this message]
2022-07-21 8:01 ` [PATCH] mm: memcontrol: fix potential oom_lock recursion deadlock Michal Hocko
2022-07-22 0:46 ` [PATCH v2] " Tetsuo Handa
2022-07-22 7:19 ` Michal Hocko
2022-07-22 10:45 ` [PATCH v3] " Tetsuo Handa
2022-07-22 11:04 ` Michal Hocko
2022-07-22 11:12 ` Tetsuo Handa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a154df77-10c0-fa44-7471-9e73b6b52a72@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox