lkml.org 
[lkml]   [2023]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] stop_machine: Avoid potential race behaviour of multi_stop_data::state
Date
From: Rong Tao <rongtao@cestc.cn>

In commit b1fc58333575 ("stop_machine: Avoid potential race behaviour")
fix both multi_cpu_stop() and set_state() access multi_stop_data::state,
We should ensure that multi_stop_data::state is accessed using the rwonce
method.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
kernel/stop_machine.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index cedb17ba158a..73de9ab77132 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -191,7 +191,7 @@ static void set_state(struct multi_stop_data *msdata,
static void ack_state(struct multi_stop_data *msdata)
{
if (atomic_dec_and_test(&msdata->thread_ack))
- set_state(msdata, msdata->state + 1);
+ set_state(msdata, READ_ONCE(msdata->state) + 1);
}

notrace void __weak stop_machine_yield(const struct cpumask *cpumask)
--
2.42.0
\
 
 \ /
  Last update: 2023-10-17 10:52    [W:0.090 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site