Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755823AbdDRLvl (ORCPT ); Tue, 18 Apr 2017 07:51:41 -0400 Received: from ozlabs.org ([103.22.144.67]:59851 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbdDRLvj (ORCPT ); Tue, 18 Apr 2017 07:51:39 -0400 X-powerpc-patch-notification: thanks X-powerpc-patch-commit: 9e1ba4f27f018742a1aa95d11e35106feba08ec1 In-Reply-To: <1491887293-3815-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> To: Ravi Bangoria From: Michael Ellerman Cc: chris@distroguy.com, npiggin@gmail.com, linux-kernel@vger.kernel.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, Ravi Bangoria , naveen.n.rao@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, anton@samba.org, viro@zeniv.linux.org.uk Subject: Re: [v2] ppc64/kprobe: Fix oops when kprobed on 'stdu' instruction Message-Id: <3w6k4T3xS7z9rxw@ozlabs.org> Date: Tue, 18 Apr 2017 21:51:37 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1379 Lines: 32 On Tue, 2017-04-11 at 05:08:13 UTC, Ravi Bangoria wrote: > If we set a kprobe on a 'stdu' instruction on powerpc64, we see a kernel > OOPS: > > [ 1275.165932] Bad kernel stack pointer cd93c840 at c000000000009868 > [ 1275.166378] Oops: Bad kernel stack pointer, sig: 6 [#1] > ... > GPR00: c000001fcd93cb30 00000000cd93c840 c0000000015c5e00 00000000cd93c840 > ... > [ 1275.178305] NIP [c000000000009868] resume_kernel+0x2c/0x58 > [ 1275.178594] LR [c000000000006208] program_check_common+0x108/0x180 > > Basically, on 64 bit system, when user probes on 'stdu' instruction, > kernel does not emulate actual store in emulate_step itself because it > may corrupt exception frame. So kernel does actual store operation in > exception return code i.e. resume_kernel(). > > resume_kernel() loads the saved stack pointer from memory using lwz, > effectively loading a corrupt (32bit) address, causing the kernel crash. > > Fix this by loading the 64bit value instead. > > Fixes: be96f63375a1 ("powerpc: Split out instruction analysis part of emulate_step()") > Signed-off-by: Ravi Bangoria > Reviewed-by: Naveen N. Rao > Reviewed-by: Ananth N Mavinakayanahalli Applied to powerpc fixes, thanks. https://git.kernel.org/powerpc/c/9e1ba4f27f018742a1aa95d11e3510 cheers