08 Mar, 2017

1 commit

  • For live patching and possibly other use cases, a stack trace is only
    useful if it can be assured that it's completely reliable. Add a new
    save_stack_trace_tsk_reliable() function to achieve that.

    Note that if the target task isn't the current task, and the target task
    is allowed to run, then it could be writing the stack while the unwinder
    is reading it, resulting in possible corruption. So the caller of
    save_stack_trace_tsk_reliable() must ensure that the task is either
    'current' or inactive.

    save_stack_trace_tsk_reliable() relies on the x86 unwinder's detection
    of pt_regs on the stack. If the pt_regs are not user-mode registers
    from a syscall, then they indicate an in-kernel interrupt or exception
    (e.g. preemption or a page fault), in which case the stack is considered
    unreliable due to the nature of frame pointers.

    It also relies on the x86 unwinder's detection of other issues, such as:

    - corrupted stack data
    - stack grows the wrong way
    - stack walk doesn't reach the bottom
    - user didn't provide a large enough entries array

    Such issues are reported by checking unwind_error() and !unwind_done().

    Also add CONFIG_HAVE_RELIABLE_STACKTRACE so arch-independent code can
    determine at build time whether the function is implemented.

    Signed-off-by: Josh Poimboeuf
    Reviewed-by: Miroslav Benes
    Acked-by: Ingo Molnar # for the x86 changes
    Signed-off-by: Jiri Kosina

    Josh Poimboeuf
     

08 Feb, 2017

1 commit

  • Since KERN_CONT became meaningful again, lockdep stack traces have had
    annoying extra newlines, like this:

    [ 5.561122] -> #1 (B){+.+...}:
    [ 5.561528]
    [ 5.561532] [] lock_acquire+0xc3/0x210
    [ 5.562178]
    [ 5.562181] [] mutex_lock_nested+0x74/0x6d0
    [ 5.562861]
    [ 5.562880] [] init_btrfs_fs+0x21/0x196 [btrfs]
    [ 5.563717]
    [ 5.563721] [] do_one_initcall+0x52/0x1b0
    [ 5.564554]
    [ 5.564559] [] do_init_module+0x5f/0x209
    [ 5.565357]
    [ 5.565361] [] load_module+0x218d/0x2b80
    [ 5.566020]
    [ 5.566021] [] SyS_finit_module+0xeb/0x120
    [ 5.566694]
    [ 5.566696] [] entry_SYSCALL_64_fastpath+0x1f/0xc2

    That's happening because each printk() call now gets printed on its own
    line, and we do a separate call to print the spaces before the symbol.
    Fix it by doing the printk() directly instead of using the
    print_ip_sym() helper.

    Additionally, the symbol address isn't very helpful, so let's get rid of
    that, too. The final result looks like this:

    [ 5.194518] -> #1 (B){+.+...}:
    [ 5.195002] lock_acquire+0xc3/0x210
    [ 5.195439] mutex_lock_nested+0x74/0x6d0
    [ 5.196491] do_one_initcall+0x52/0x1b0
    [ 5.196939] do_init_module+0x5f/0x209
    [ 5.197355] load_module+0x218d/0x2b80
    [ 5.197792] SyS_finit_module+0xeb/0x120
    [ 5.198251] entry_SYSCALL_64_fastpath+0x1f/0xc2

    Suggested-by: Linus Torvalds
    Signed-off-by: Omar Sandoval
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: kernel-team@fb.com
    Fixes: 4bcc595ccd80 ("printk: reinstate KERN_CONT for printing continuation lines")
    Link: http://lkml.kernel.org/r/43b4e114724b2bdb0308fa86cb33aa07d3d67fad.1486510315.git.osandov@fb.com
    Signed-off-by: Ingo Molnar

    Omar Sandoval
     

14 Dec, 2014

1 commit

  • Current stacktrace only have the function for console output. page_owner
    that will be introduced in following patch needs to print the output of
    stacktrace into the buffer for our own output format so so new function,
    snprint_stack_trace(), is needed.

    Signed-off-by: Joonsoo Kim
    Cc: Mel Gorman
    Cc: Johannes Weiner
    Cc: Minchan Kim
    Cc: Dave Hansen
    Cc: Michal Nazarewicz
    Cc: Jungsoo Son
    Cc: Ingo Molnar
    Cc: Joonsoo Kim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joonsoo Kim
     

31 Oct, 2011

1 commit

  • The changed files were only including linux/module.h for the
    EXPORT_SYMBOL infrastructure, and nothing else. Revector them
    onto the isolated export header for faster compile times.

    Nothing to see here but a whole lot of instances of:

    -#include
    +#include

    This commit is only changing the kernel dir; next targets
    will probably be mm, fs, the arch dirs, etc.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

15 Jun, 2011

1 commit

  • Add weak symbol of save_stack_trace_regs() as same as
    save_stack_trace_tsk() since that is not implemented
    except x86 yet.

    Signed-off-by: Masami Hiramatsu
    Cc: Frederic Weisbecker
    Cc: yrl.pp-manager.tt@hitachi.com
    Cc: Peter Zijlstra
    Cc: Namhyung Kim
    Link: http://lkml.kernel.org/r/20110608070927.17777.37895.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

25 Dec, 2008

1 commit


30 Jun, 2008

1 commit


13 Jun, 2008

1 commit


24 May, 2008

1 commit

  • This patch makes the stacktrace printout code \warn when the entries
    pointer is unset rather than crashing when trying to access it in an
    attempt to make it a bit more robust.

    I was saving a stacktrace into an skb and forgot to copy it across skb
    copies... I have since fixed the code, but it would have been easier
    had the kernel not crashed in an interrupt.

    Signed-off-by: Johannes Berg
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    Johannes Berg
     

04 Jul, 2006

1 commit