lkml.org 
[lkml]   [2021]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm,hwpoison: Don't call task_work_add when there is same work in the queue
Date
queue_task_work can be called more than once in one task before
this task work is running. it can lead to task->task_works becomes
an endless loop list and the task will never return to user mode.
Don't call task_work_add when there is same work in the queue.

Signed-off-by: yaozhenguo <yaozhenguo1@gmail.com>
---
arch/x86/kernel/cpu/mce/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 22791aa..62c67ad 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1299,7 +1299,9 @@ static void queue_task_work(struct mce *m, int kill_current_task)
else
current->mce_kill_me.func = kill_me_maybe;

- task_work_add(current, &current->mce_kill_me, TWA_RESUME);
+ /* Avoid endless loops in task_work_run */
+ if (READ_ONCE(current->task_works) != &current->mce_kill_me)
+ task_work_add(current, &current->mce_kill_me, TWA_RESUME);
}

/*
--
1.8.3.1
\
 
 \ /
  Last update: 2021-07-09 11:29    [W:0.040 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site