Skip to content

Commit

Permalink
powerpc: get_wchan(): solve possible race scenario due to parallel wa…
Browse files Browse the repository at this point in the history
…keup

Add a check for p->state == TASK_RUNNING so that any wake-ups on
task_struct p in the interim lead to 0 being returned by get_wchan().

Signed-off-by: Kautuk Consul <kautuk.consul.1980@gmail.com>
[mpe: Confirmed other architectures do similar]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Kautuk Consul authored and Michael Ellerman committed Oct 6, 2017
1 parent 06755a8 commit 4ca360f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/powerpc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,8 @@ unsigned long get_wchan(struct task_struct *p)

do {
sp = *(unsigned long *)sp;
if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD))
if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) ||
p->state == TASK_RUNNING)
return 0;
if (count > 0) {
ip = ((unsigned long *)sp)[STACK_FRAME_LR_SAVE];
Expand Down

0 comments on commit 4ca360f

Please sign in to comment.