Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753226AbdDKGBx (ORCPT ); Tue, 11 Apr 2017 02:01:53 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60672 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751273AbdDKGBw (ORCPT ); Tue, 11 Apr 2017 02:01:52 -0400 Date: Tue, 11 Apr 2017 11:31:43 +0530 From: Ananth N Mavinakayanahalli To: Ravi Bangoria Cc: mpe@ellerman.id.au, chris@distroguy.com, npiggin@gmail.com, linux-kernel@vger.kernel.org, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, anton@samba.org, viro@zeniv.linux.org.uk Subject: Re: [PATCH v2] ppc64/kprobe: Fix oops when kprobed on 'stdu' instruction Reply-To: ananth@linux.vnet.ibm.com References: <1491887293-3815-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1491887293-3815-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17041106-0024-0000-0000-000016383239 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006915; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00845895; UDB=6.00417180; IPR=6.00624328; BA=6.00005282; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015000; XFM=3.00000013; UTC=2017-04-11 06:01:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041106-0025-0000-0000-00004A284FEB Message-Id: <20170411060143.GC5926@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-11_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704110053 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1277 Lines: 27 On Tue, Apr 11, 2017 at 10:38:13AM +0530, 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