0245-x86-dumpstack-Print-registers-for-first-stack-frame.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Josh Poimboeuf <[email protected]>
  3. Date: Sun, 31 Dec 2017 10:18:07 -0600
  4. Subject: [PATCH] x86/dumpstack: Print registers for first stack frame
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. In the stack dump code, if the frame after the starting pt_regs is also
  10. a regs frame, the registers don't get printed. Fix that.
  11. Reported-by: Andy Lutomirski <[email protected]>
  12. Tested-by: Alexander Tsoy <[email protected]>
  13. Signed-off-by: Josh Poimboeuf <[email protected]>
  14. Cc: Andy Lutomirski <[email protected]>
  15. Cc: Linus Torvalds <[email protected]>
  16. Cc: Peter Zijlstra <[email protected]>
  17. Cc: Thomas Gleixner <[email protected]>
  18. Cc: Toralf Förster <[email protected]>
  19. Cc: [email protected]
  20. Fixes: 3b3fa11bc700 ("x86/dumpstack: Print any pt_regs found on the stack")
  21. Link: http://lkml.kernel.org/r/396f84491d2f0ef64eda4217a2165f5712f6a115.1514736742.git.jpoimboe@redhat.com
  22. Signed-off-by: Ingo Molnar <[email protected]>
  23. (cherry picked from commit 3ffdeb1a02be3086f1411a15c5b9c481fa28e21f)
  24. Signed-off-by: Andy Whitcroft <[email protected]>
  25. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  26. (cherry picked from commit 3aef1ce621ae2eb0bd58e07cf9e66a859faa17cd)
  27. Signed-off-by: Fabian Grünbichler <[email protected]>
  28. ---
  29. arch/x86/kernel/dumpstack.c | 3 ++-
  30. 1 file changed, 2 insertions(+), 1 deletion(-)
  31. diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
  32. index 8da5b487919f..042f80c50e3b 100644
  33. --- a/arch/x86/kernel/dumpstack.c
  34. +++ b/arch/x86/kernel/dumpstack.c
  35. @@ -115,6 +115,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
  36. unwind_start(&state, task, regs, stack);
  37. stack = stack ? : get_stack_pointer(task, regs);
  38. + regs = unwind_get_entry_regs(&state, &partial);
  39. /*
  40. * Iterate through the stacks, starting with the current stack pointer.
  41. @@ -132,7 +133,7 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
  42. * - hardirq stack
  43. * - entry stack
  44. */
  45. - for (regs = NULL; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
  46. + for ( ; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
  47. const char *stack_name;
  48. if (get_stack_info(stack, task, &stack_info, &visit_mask)) {
  49. --
  50. 2.14.2