Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1500921

[PATCH 4.8 28/37] x86/dumpstack: Fix x86_32 kernel_stack_pointer() previous stack access

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.8 28/37] x86/dumpstack: Fix x86_32 kernel_stack_pointer() previous stack access
Date 2016-10-14 14:40 +0200
Message-ID <ss9Wi-1g1-29@gated-at.bofh.it> (permalink)
References <ss9MB-1cq-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.8-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Josh Poimboeuf <jpoimboe@redhat.com>

commit 72b4f6a5e903b071f2a7c4eb1418cbe4eefdc344 upstream.

On x86_32, when an interrupt happens from kernel space, SS and SP aren't
pushed and the existing stack is used.  So pt_regs is effectively two
words shorter, and the previous stack pointer is normally the memory
after the shortened pt_regs, aka '&regs->sp'.

But in the rare case where the interrupt hits right after the stack
pointer has been changed to point to an empty stack, like for example
when call_on_stack() is used, the address immediately after the
shortened pt_regs is no longer on the stack.  In that case, instead of
'&regs->sp', the previous stack pointer should be retrieved from the
beginning of the current stack page.

kernel_stack_pointer() wants to do that, but it forgets to dereference
the pointer.  So instead of returning a pointer to the previous stack,
it returns a pointer to the beginning of the current stack.

Note that it's probably outside of kernel_stack_pointer()'s scope to be
switching stacks at all.  The x86_64 version of this function doesn't do
it, and it would be better for the caller to do it if necessary.  But
that's a patch for another day.  This just fixes the original intent.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 0788aa6a23cb ("x86: Prepare removal of previous_esp from i386 thread_info structure")
Link: http://lkml.kernel.org/r/472453d6e9f6a2d4ab16aaed4935f43117111566.1471535549.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/ptrace.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -173,8 +173,8 @@ unsigned long kernel_stack_pointer(struc
 		return sp;
 
 	prev_esp = (u32 *)(context);
-	if (prev_esp)
-		return (unsigned long)prev_esp;
+	if (*prev_esp)
+		return (unsigned long)*prev_esp;
 
 	return (unsigned long)regs;
 }

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.8 00/37] 4.8.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 27/37] x86/mm/pkeys: Do not skip PKRU register if debug registers are not used Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 19/37] x86/boot: Fix kdump, cleanup aborted E820_PRAM max_pfn manipulation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 24/37] x86/platform/intel-mid: Keep SRAM powered on at boot Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 17/37] KVM: PPC: BookE: Fix a sanity check Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 20/37] x86/irq: Prevent force migration of irqs which are not in the vector domain Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 01/37] usb: storage: fix runtime pm issue in usb_stor_probe2 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 18/37] arm64: fix dump_backtrace/unwind_frame with NULL tsk Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 16/37] KVM: arm/arm64: vgic: Dont flush/sync without a working vgic Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:30 +0200
  [PATCH 4.8 08/37] mfd: rtsx_usb: Avoid setting ucr->current_sg.status Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 37/37] tpm_crb: fix crb_req_canceled behavior Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 26/37] arch/x86: Handle non enumerated CPU after physical hotplug Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 02/37] timekeeping: Fix __ktime_get_fast_ns() regression Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 34/37] Bluetooth: Add a new 04ca:3011 QCA_ROME device Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 22/37] x86/cpu: Rename Merrifield2 to Moorefield Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 05/37] ALSA: ali5451: Fix out-of-bound position reporting Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 36/37] tpm: fix a race condition in tpm2_unseal_trusted() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 30/37] ARM: dts: mvebu: armada-390: add missing compatibility string and bracket Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 07/37] ALSA: usb-line6: use the same declaration as definition in header for MIDI manufacturer ID Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 28/37] x86/dumpstack: Fix x86_32 kernel_stack_pointer() previous stack access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 12/37] xen/x86: Update topology map for PV VCPUs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 35/37] ima: use file_dentry() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 06/37] ALSA: usb-audio: Extend DragonFly dB scale quirk to cover other variants Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 04/37] phy: sun4i-usb: Use spinlock to guard phyctl register access Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 09/37] mfd: atmel-hlcdc: Do not sleep in atomic context Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 03/37] usb: dwc3: fix Clear Stall EP command failure Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 23/37] x86/platform/intel-mid: Add Intel Penwell to ID table Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 33/37] ARM: cpuidle: Fix error return code Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  [PATCH 4.8 21/37] x86/pkeys: Make protection keys an "eager" feature Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-14 14:40 +0200
  Re: [PATCH 4.8 00/37] 4.8.2-stable review Shuah Khan <shuah.kh@samsung.com> - 2016-10-14 21:00 +0200
    Re: [PATCH 4.8 00/37] 4.8.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-15 14:10 +0200
  Re: [PATCH 4.8 00/37] 4.8.2-stable review Guenter Roeck <linux@roeck-us.net> - 2016-10-14 21:20 +0200
    Re: [PATCH 4.8 00/37] 4.8.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-15 14:10 +0200
  Re: [PATCH 4.8 00/37] 4.8.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-15 13:40 +0200
    Re: [PATCH 4.8 00/37] 4.8.2-stable review Kevin Hilman <khilman@baylibre.com> - 2016-10-17 18:50 +0200

csiph-web