From: Shuai Xue <xueshuai@linux.alibaba.com>
To: naoya.horiguchi@nec.com, linmiaohe@huawei.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
cuibixuan@linux.alibaba.com, baolin.wang@linux.alibaba.com,
zhuo.song@linux.alibaba.com, xueshuai@linux.alibaba.com
Subject: [PATCH] mm,hwpoison: check mm when killing accessing process
Date: Wed, 14 Sep 2022 14:49:35 +0800 [thread overview]
Message-ID: <20220914064935.7851-1-xueshuai@linux.alibaba.com> (raw)
The GHES code calls memory_failure_queue() from IRQ context to queue work
into workqueue and schedule it on the current CPU. Then the work is
processed in memory_failure_work_func() by kworker and calls
memory_failure().
When a page is already poisoned, commit a3f5d80ea401 ("mm,hwpoison: send
SIGBUS with error virutal address") make memory_failure() call
kill_accessing_process() that:
- holds mmap locking of current->mm
- does pagetable walk to find the error virtual address
- and sends SIGBUS to the current process with error info.
However, the mm of kworker is not valid. Therefore, check mm when killing
accessing process.
Fixes: a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address")
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
---
mm/memory-failure.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 14439806b5ef..7553917ce820 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -743,6 +743,9 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn,
};
priv.tk.tsk = p;
+ if (!p->mm)
+ return -EFAULT;
+
mmap_read_lock(p->mm);
ret = walk_page_range(p->mm, 0, TASK_SIZE, &hwp_walk_ops,
(void *)&priv);
@@ -751,6 +754,7 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn,
else
ret = 0;
mmap_read_unlock(p->mm);
+
return ret > 0 ? -EHWPOISON : -EFAULT;
}
--
2.20.1.12.g72788fdb
next reply other threads:[~2022-09-14 6:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 6:49 Shuai Xue [this message]
2022-09-14 22:35 ` Andrew Morton
2022-09-15 1:36 ` Shuai Xue
2022-09-15 1:45 ` Miaohe Lin
2022-09-15 2:06 ` Shuai Xue
2022-09-15 1:48 ` Naoya Horiguchi
2022-09-15 2:08 ` Shuai Xue
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=20220914064935.7851-1-xueshuai@linux.alibaba.com \
--to=xueshuai@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=cuibixuan@linux.alibaba.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=zhuo.song@linux.alibaba.com \
/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