Skip to content

Commit 1bba390

Browse files
ZqiangNeeraj Upadhyay (AMD)
authored andcommitted
rcu/nocb: Fix possible invalid rdp's->nocb_cb_kthread pointer access
In the preparation stage of CPU online, if the corresponding the rdp's->nocb_cb_kthread does not exist, will be created, there is a situation where the rdp's rcuop kthreads creation fails, and then de-offload this CPU's rdp, does not assign this CPU's rdp->nocb_cb_kthread pointer, but this rdp's->nocb_gp_rdp and rdp's->rdp_gp->nocb_gp_kthread is still valid. This will cause the subsequent re-offload operation of this offline CPU, which will pass the conditional check and the kthread_unpark() will access invalid rdp's->nocb_cb_kthread pointer. This commit therefore use rdp's->nocb_gp_kthread instead of rdp_gp's->nocb_gp_kthread for safety check. Signed-off-by: Zqiang <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Signed-off-by: Neeraj Upadhyay (AMD) <[email protected]>
1 parent a33ad03 commit 1bba390

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

kernel/rcu/tree_nocb.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,6 @@ static bool rcu_nocb_rdp_offload_wait_cond(struct rcu_data *rdp)
11461146
static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
11471147
{
11481148
int wake_gp;
1149-
struct rcu_data *rdp_gp = rdp->nocb_gp_rdp;
11501149

11511150
WARN_ON_ONCE(cpu_online(rdp->cpu));
11521151
/*
@@ -1156,7 +1155,7 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
11561155
if (!rdp->nocb_gp_rdp)
11571156
return -EINVAL;
11581157

1159-
if (WARN_ON_ONCE(!rdp_gp->nocb_gp_kthread))
1158+
if (WARN_ON_ONCE(!rdp->nocb_gp_kthread))
11601159
return -EINVAL;
11611160

11621161
pr_info("Offloading %d\n", rdp->cpu);
@@ -1166,7 +1165,7 @@ static int rcu_nocb_rdp_offload(struct rcu_data *rdp)
11661165

11671166
wake_gp = rcu_nocb_queue_toggle_rdp(rdp);
11681167
if (wake_gp)
1169-
wake_up_process(rdp_gp->nocb_gp_kthread);
1168+
wake_up_process(rdp->nocb_gp_kthread);
11701169

11711170
swait_event_exclusive(rdp->nocb_state_wq,
11721171
rcu_nocb_rdp_offload_wait_cond(rdp));

0 commit comments

Comments
 (0)