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>
if (regs)
return (unsigned long *)regs->bp;
if (regs)
return (unsigned long *)regs->bp;
- if (!task || task == current)
return __builtin_frame_address(0);
return (unsigned long *)((struct inactive_task_frame *)task->thread.sp)->bp;
return __builtin_frame_address(0);
return (unsigned long *)((struct inactive_task_frame *)task->thread.sp)->bp;
if (regs)
return (unsigned long *)kernel_stack_pointer(regs);
if (regs)
return (unsigned long *)kernel_stack_pointer(regs);
- if (!task || task == current)
return __builtin_frame_address(0);
return (unsigned long *)task->thread.sp;
return __builtin_frame_address(0);
return (unsigned long *)task->thread.sp;
+ task = task ? : current;
+
/*
* Stack frames below this one aren't interesting. Don't show them
* if we're printing for %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);
}
sp = get_stack_pointer(current, NULL);
bp = (unsigned long)get_frame_pointer(current, NULL);
}
u8 *ip;
pr_emerg("Stack:\n");
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);
u8 *ip;
printk(KERN_DEFAULT "Stack:\n");
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: ");
printk(KERN_DEFAULT "Code: ");