summaryrefslogtreecommitdiffstats
path: root/mm/memory-failure.c
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2022-08-23 11:23:44 +0800
committerAndrew Morton <akpm@linux-foundation.org>2022-09-11 20:25:57 -0700
commit54f9555d4031d4aeb10651aa9dcb5335f6a05865 (patch)
treeba6dc8827168dbe5964bb3f8571b2263b5e96af4 /mm/memory-failure.c
parent12f1dbcf8f144c0b8dde7a62fea766f88cb79fc8 (diff)
downloadlinux-stable-54f9555d4031d4aeb10651aa9dcb5335f6a05865.tar.gz
linux-stable-54f9555d4031d4aeb10651aa9dcb5335f6a05865.tar.bz2
linux-stable-54f9555d4031d4aeb10651aa9dcb5335f6a05865.zip
mm, hwpoison: fix possible use-after-free in mf_dax_kill_procs()
After kill_procs(), tk will be freed without being removed from the to_kill list. In the next iteration, the freed list entry in the to_kill list will be accessed, thus leading to use-after-free issue. Adding list_del() in kill_procs() to fix the issue. Link: https://lkml.kernel.org/r/20220823032346.4260-5-linmiaohe@huawei.com Fixes: c36e20249571 ("mm: introduce mf_dax_kill_procs() for fsdax case") Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/memory-failure.c')
-rw-r--r--mm/memory-failure.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 799176d3f5f7..208a0f85ef54 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -413,7 +413,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
{
struct to_kill *tk, *next;
- list_for_each_entry_safe (tk, next, to_kill, nd) {
+ list_for_each_entry_safe(tk, next, to_kill, nd) {
if (forcekill) {
/*
* In case something went wrong with munmapping
@@ -437,6 +437,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
pr_err("%#lx: Cannot send advisory machine check signal to %s:%d\n",
pfn, tk->tsk->comm, tk->tsk->pid);
}
+ list_del(&tk->nd);
put_task_struct(tk->tsk);
kfree(tk);
}