Skip to contentSkip to conversation

powerpc: set stack limit properly in crit_transfer_to_handler

PATCH In review Stuart Yoder 3 participants 3 messages Jul 16, 2012 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: set stack limit properly in crit_transfer_to_handler

From: Stuart Yoder <[email protected]>

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

---
 arch/powerpc/kernel/entry_32.S |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
arch/powerpc/kernel/entry_32.S +10 -2
index 5207d5a..ead5016 100644
@@ -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
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 10 lines · Stuart Yoder

From: Stuart Yoder <[email protected]>

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

---
arch/powerpc/kernel/entry_32.S | 12 ++++++++++--

1 files changed, 10 insertions(+), 2 deletions(-)

Do we need this for debug & mcheck ?

- k

#2 lore raw
Quoted 7 lines

-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Monday, July 16, 2012 3:36 PM
To: Yoder Stuart-B08248
Cc: [email protected]; [email protected]; [email protected]; lin=

[email protected];

Quoted 2 lines

[email protected]
Subject: Re: [PATCH] powerpc: set stack limit properly in crit_transfer_t=

o_handler

Quoted 10 lines

=20
=20
On Jul 16, 2012, at 2:06 PM, Stuart Yoder wrote:
=20

Quoted 6 lines

From: Stuart Yoder <[email protected]>

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

Quoted 6 lines
Quoted 4 lines

---
arch/powerpc/kernel/entry_32.S | 12 ++++++++++--

1 files changed, 10 insertions(+), 2 deletions(-)

=20
Do we need this for debug & mcheck ?

Maybe... I don't know the history of this code and why this is only done in the critical exception handlers.

But, this particular patch is to undo/fix something I introduced in:
powerpc: Use CURRENT_THREAD_INFO instead of open coded assembly

Stuart