aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc
diff options
context:
space:
mode:
authorJohn David Anglin <dave.anglin@bell.net>2016-10-28 23:00:34 -0400
committerHelge Deller <deller@gmx.de>2016-11-02 18:05:30 -0400
commit6ed518328d0189e0fdf1bb7c73290d546143ea66 (patch)
tree177a971638fed789cd8972580e89d6aaa466c73a /arch/parisc
parentf4125cfdb3008363137f744c101e5d76ead760ba (diff)
parisc: Ensure consistent state when switching to kernel stack at syscall entry
We have one critical section in the syscall entry path in which we switch from the userspace stack to kernel stack. In the event of an external interrupt, the interrupt code distinguishes between those two states by analyzing the value of sr7. If sr7 is zero, it uses the kernel stack. Therefore it's important, that the value of sr7 is in sync with the currently enabled stack. This patch now disables interrupts while executing the critical section. This prevents the interrupt handler to possibly see an inconsistent state which in the worst case can lead to crashes. Interestingly, in the syscall exit path interrupts were already disabled in the critical section which switches back to the userspace stack. Cc: <stable@vger.kernel.org> Signed-off-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'arch/parisc')
-rw-r--r--arch/parisc/kernel/syscall.S11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index 40190dbecdc0..deec1f8465e5 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -106,8 +106,6 @@ linux_gateway_entry:
106 mtsp %r0,%sr4 /* get kernel space into sr4 */ 106 mtsp %r0,%sr4 /* get kernel space into sr4 */
107 mtsp %r0,%sr5 /* get kernel space into sr5 */ 107 mtsp %r0,%sr5 /* get kernel space into sr5 */
108 mtsp %r0,%sr6 /* get kernel space into sr6 */ 108 mtsp %r0,%sr6 /* get kernel space into sr6 */
109 mfsp %sr7,%r1 /* save user sr7 */
110 mtsp %r1,%sr3 /* and store it in sr3 */
111 109
112#ifdef CONFIG_64BIT 110#ifdef CONFIG_64BIT
113 /* for now we can *always* set the W bit on entry to the syscall 111 /* for now we can *always* set the W bit on entry to the syscall
@@ -133,6 +131,14 @@ linux_gateway_entry:
133 depdi 0, 31, 32, %r21 131 depdi 0, 31, 32, %r21
1341: 1321:
135#endif 133#endif
134
135 /* We use a rsm/ssm pair to prevent sr3 from being clobbered
136 * by external interrupts.
137 */
138 mfsp %sr7,%r1 /* save user sr7 */
139 rsm PSW_SM_I, %r0 /* disable interrupts */
140 mtsp %r1,%sr3 /* and store it in sr3 */
141
136 mfctl %cr30,%r1 142 mfctl %cr30,%r1
137 xor %r1,%r30,%r30 /* ye olde xor trick */ 143 xor %r1,%r30,%r30 /* ye olde xor trick */
138 xor %r1,%r30,%r1 144 xor %r1,%r30,%r1
@@ -147,6 +153,7 @@ linux_gateway_entry:
147 */ 153 */
148 154
149 mtsp %r0,%sr7 /* get kernel space into sr7 */ 155 mtsp %r0,%sr7 /* get kernel space into sr7 */
156 ssm PSW_SM_I, %r0 /* enable interrupts */
150 STREGM %r1,FRAME_SIZE(%r30) /* save r1 (usp) here for now */ 157 STREGM %r1,FRAME_SIZE(%r30) /* save r1 (usp) here for now */
151 mfctl %cr30,%r1 /* get task ptr in %r1 */ 158 mfctl %cr30,%r1 /* get task ptr in %r1 */
152 LDREG TI_TASK(%r1),%r1 159 LDREG TI_TASK(%r1),%r1