From patchwork Mon Jul 16 19:06:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Yoder X-Patchwork-Id: 171234 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 0B8B12C055A for ; Tue, 17 Jul 2012 05:08:04 +1000 (EST) Received: from am1outboundpool.messaging.microsoft.com (am1ehsobe003.messaging.microsoft.com [213.199.154.206]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 90FBA2C0102 for ; Tue, 17 Jul 2012 05:07:34 +1000 (EST) Received: from mail70-am1-R.bigfish.com (10.3.201.247) by AM1EHSOBE006.bigfish.com (10.3.204.26) with Microsoft SMTP Server id 14.1.225.23; Mon, 16 Jul 2012 19:07:28 +0000 Received: from mail70-am1 (localhost [127.0.0.1]) by mail70-am1-R.bigfish.com (Postfix) with ESMTP id DC4E9420114; Mon, 16 Jul 2012 19:07:27 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah) Received: from mail70-am1 (localhost.localdomain [127.0.0.1]) by mail70-am1 (MessageSwitch) id 1342465628471075_17443; Mon, 16 Jul 2012 19:07:08 +0000 (UTC) Received: from AM1EHSMHS001.bigfish.com (unknown [10.3.201.253]) by mail70-am1.bigfish.com (Postfix) with ESMTP id 4DC6A300377; Mon, 16 Jul 2012 19:07:03 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS001.bigfish.com (10.3.207.101) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 16 Jul 2012 19:07:00 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Mon, 16 Jul 2012 14:06:58 -0500 Received: from right.am.freescale.net (right.am.freescale.net [10.82.176.228]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id q6GJ6shE004147; Mon, 16 Jul 2012 12:06:56 -0700 From: Stuart Yoder To: Subject: [PATCH] powerpc: set stack limit properly in crit_transfer_to_handler Date: Mon, 16 Jul 2012 14:06:48 -0500 Message-ID: <1342465608-20596-1-git-send-email-stuart.yoder@freescale.com> X-Mailer: git-send-email 1.7.3.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: sfr@canb.auug.org.au, Stuart Yoder , paulus@samba.org, linuxppc-dev@lists.ozlabs.org, agraf@suse.de X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Stuart Yoder without setting the stack limit like this there is the possibility of stack overflow which corrupts the thread info but is not detected by stack overflow detection Signed-off-by: Stuart Yoder --- arch/powerpc/kernel/entry_32.S | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S index 5207d5a..ead5016 100644 --- a/arch/powerpc/kernel/entry_32.S +++ b/arch/powerpc/kernel/entry_32.S @@ -89,10 +89,14 @@ crit_transfer_to_handler: mfspr r0,SPRN_SRR1 stw r0,_SRR1(r11) + /* set the stack limit to the current stack + * and set the limit to protect the thread_info + * struct + */ mfspr r8,SPRN_SPRG_THREAD lwz r0,KSP_LIMIT(r8) stw r0,SAVED_KSP_LIMIT(r11) - CURRENT_THREAD_INFO(r0, r1) + rlwimi r0,r1,0,0,(31-THREAD_SHIFT) stw r0,KSP_LIMIT(r8) /* fall through */ #endif @@ -109,10 +113,14 @@ crit_transfer_to_handler: mfspr r0,SPRN_SRR1 stw r0,crit_srr1@l(0) + /* set the stack limit to the current stack + * and set the limit to protect the thread_info + * struct + */ mfspr r8,SPRN_SPRG_THREAD lwz r0,KSP_LIMIT(r8) stw r0,saved_ksp_limit@l(0) - CURRENT_THREAD_INFO(r0, r1) + rlwimi r0,r1,0,0,(31-THREAD_SHIFT) stw r0,KSP_LIMIT(r8) /* fall through */ #endif