Skip to content

Commit 039a7a3

Browse files
jpoimboeKAGA-KOKO
authored andcommitted
x86/stacktrace: Fix reliable check for empty user task stacks
If a user task's stack is empty, or if it only has user regs, ORC reports it as a reliable empty stack. But arch_stack_walk_reliable() incorrectly treats it as unreliable. That happens because the only success path for user tasks is inside the loop, which only iterates on non-empty stacks. Generally, a user task must end in a user regs frame, but an empty stack is an exception to that rule. Thanks to commit 71c9582 ("x86/unwind/orc: Fix error handling in __unwind_start()"), unwind_start() now sets state->error appropriately. So now for both ORC and FP unwinders, unwind_done() and !unwind_error() always means the end of the stack was successfully reached. So the success path for kthreads is no longer needed -- it can also be used for empty user tasks. Reported-by: Wang ShaoBo <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Wang ShaoBo <[email protected]> Link: https://lkml.kernel.org/r/f136a4e5f019219cbc4f4da33b30c2f44fa65b84.1594994374.git.jpoimboe@redhat.com
1 parent 372a8ea commit 039a7a3

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

arch/x86/kernel/stacktrace.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry,
5858
* or a page fault), which can make frame pointers
5959
* unreliable.
6060
*/
61-
6261
if (IS_ENABLED(CONFIG_FRAME_POINTER))
6362
return -EINVAL;
6463
}
@@ -81,10 +80,6 @@ int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry,
8180
if (unwind_error(&state))
8281
return -EINVAL;
8382

84-
/* Success path for non-user tasks, i.e. kthreads and idle tasks */
85-
if (!(task->flags & (PF_KTHREAD | PF_IDLE)))
86-
return -EINVAL;
87-
8883
return 0;
8984
}
9085

0 commit comments

Comments
 (0)