summaryrefslogtreecommitdiff
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2016-09-16 13:05:20 (GMT)
committerIngo Molnar <mingo@kernel.org>2016-09-16 14:21:39 (GMT)
commit81539169f283329fd8bc58457cc15754f683ba69 (patch)
tree2172bf58d81411a56750134aaa08109a0b910c82 /arch/x86/kernel
parentac496bf48d97f2503eaa353996a4dd5e4383eaf0 (diff)
downloadlinux-81539169f283329fd8bc58457cc15754f683ba69.tar.xz
x86/dumpstack: Remove NULL task pointer convention
show_stack_log_lvl() and friends allow a NULL pointer for the task_struct to indicate the current task. This creates confusion and can cause sneaky bugs. Instead require the caller to pass 'current' directly. This only changes the internal workings of the dumpstack code. The dump_trace() and show_stack() interfaces still allow a NULL task pointer. Those interfaces should also probably be fixed as well. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/dumpstack.c4
-rw-r--r--arch/x86/kernel/dumpstack_32.c2
-rw-r--r--arch/x86/kernel/dumpstack_64.c2
3 files changed, 5 insertions, 3 deletions
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index aa208e5..e0648f7 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -175,11 +175,13 @@ void show_stack(struct task_struct *task, unsigned long *sp)
{
unsigned long bp = 0;
+ task = task ? : current;
+
/*
* Stack frames below this one aren't interesting. Don't show them
* if we're printing for %current.
*/
- if (!sp && (!task || task == current)) {
+ if (!sp && task == current) {
sp = get_stack_pointer(current, NULL);
bp = (unsigned long)get_frame_pointer(current, NULL);
}
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 122f37d7..4ff0008 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -205,7 +205,7 @@ void show_regs(struct pt_regs *regs)
u8 *ip;
pr_emerg("Stack:\n");
- show_stack_log_lvl(NULL, regs, NULL, 0, KERN_EMERG);
+ show_stack_log_lvl(current, regs, NULL, 0, KERN_EMERG);
pr_emerg("Code:");
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 16c0d5f..008a298 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -278,7 +278,7 @@ void show_regs(struct pt_regs *regs)
u8 *ip;
printk(KERN_DEFAULT "Stack:\n");
- show_stack_log_lvl(NULL, regs, NULL, 0, KERN_DEFAULT);
+ show_stack_log_lvl(current, regs, NULL, 0, KERN_DEFAULT);
printk(KERN_DEFAULT "Code: ");