s390: show_task oops.
PATCH 5/13 s390: show_task oops.
From: Heiko Carstens <[email protected]>
[patch 5/13] s390: show_task oops.
The show_task function walks the kernel stack backchain of processes assuming that the processes are not running. Since this assumption is not correct walking the backchain can lead to an addressing exception and therefore to a kernel hang. So prevent the kernel hang (you still get incorrect results) verity that all read accesses are within the bounds of the kernel stack before performing them.
---
arch/s390/kernel/process.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
arch/s390/kernel/process.c +12 -3
@@ -58,10 +58,19 @@ asmlinkage void ret_from_fork(void) __as*/ unsigned long thread_saved_pc (struct task_struct *tsk) { -struct stack_frame *sf; +struct stack_frame *sf, *low, *high; - sf = (struct stack_frame *) tsk->thread.ksp; - sf = (struct stack_frame *) sf->back_chain; +if (!tsk || !tsk->thread_info) +return 0 ; + low = (struct stack_frame *) tsk->thread_info; + high = (struct stack_frame *) + ((unsigned long ) tsk->thread_info +THREAD_SIZE ) -1 ; + sf = (struct stack_frame *) (tsk->thread.ksp &PSW_ADDR_INSN ); +if (sf <= low || sf > high) +return 0 ; + sf = (struct stack_frame *) (sf->back_chain &PSW_ADDR_INSN ); +if (sf <= low || sf > high) +return 0 ;return sf->gprs[8 ]; }
Quoted 5 lines · Martin Schwidefsky
From: Heiko Carstens <[email protected]>
[patch 5/13] s390:
show_taskoops.
Quoted 8 lines
The
show_taskfunction walks the kernel stack backchain of processes assuming that the processes are not running. Since this assumption is not correct walking the backchain can lead to an addressing exception and therefore to a kernel hang. So prevent the kernel hang (you still get incorrect results) verity that all read accesses are within the bounds of the kernel stack before performing them.
This one needs to be thought about and tested versus the just-merged s390-task_stack_page.patch. I guess it'll still work, but some of the pretty new accessors could be used in there, at least.
Quoted 25 lines
arch/s390/kernel/process.c +12
-3@@ -58,10 +58,19 @@ asmlinkage void ret_from_fork(void) __as*/ unsigned long thread_saved_pc (struct task_struct *tsk) { -struct stack_frame *sf; +struct stack_frame *sf, *low, *high; - sf = (struct stack_frame *) tsk->thread.ksp; - sf = (struct stack_frame *) sf->back_chain; +if (!tsk || !tsk->thread_info) +return 0 ; + low = (struct stack_frame *) tsk->thread_info; + high = (struct stack_frame *) + ((unsigned long ) tsk->thread_info +THREAD_SIZE ) -1 ; + sf = (struct stack_frame *) (tsk->thread.ksp &PSW_ADDR_INSN ); +if (sf <= low || sf > high) +return 0 ; + sf = (struct stack_frame *) (sf->back_chain &PSW_ADDR_INSN ); +if (sf <= low || sf > high) +return 0 ;return sf->gprs[8 ]; }
Quoted 15 lines · Andrew Morton
Quoted 5 lines · Martin Schwidefsky
From: Heiko Carstens <[email protected]>
[patch 5/13] s390:
show_taskoops.Quoted 8 lines
The
show_taskfunction walks the kernel stack backchain of processes assuming that the processes are not running. Since this assumption is not correct walking the backchain can lead to an addressing exception and therefore to a kernel hang. So prevent the kernel hang (you still get incorrect results) verity that all read accesses are within the bounds of the kernel stack before performing them.
Quoted 3 lines
This one needs to be thought about and tested versus the just-merged s390-task_stack_page.patch. I guess it'll still work, but some of the pretty new accessors could be used in there, at least.
Oh yes, didn't notice that Al Viro's task_thread_info() changes got merged in the meantime. We'll test & send a follow-up patch.
Signature · 6 lines
blue skies, Martin Martin Schwidefsky Linux for zSeries Development & Services IBM Deutschland Entwicklung GmbH
PATCH 1/1 s390: show_task oops fix
From: Heiko Carstens <[email protected]>
Use new stack page accessors as pointed out by Andrew Morton.
---
arch/s390/kernel/process.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/s390/kernel/process.c +3 -4
@@ -60,11 +60,10 @@ {struct stack_frame *sf, *low, *high; -if (!tsk || !tsk->thread_info) +if (!tsk || !task_stack_page (tsk))return 0 ; - low = (struct stack_frame *) tsk->thread_info; - high = (struct stack_frame *) - ((unsigned long ) tsk->thread_info +THREAD_SIZE ) -1 ; + low =task_stack_page (tsk); + high = (struct stack_frame *)task_pt_regs (tsk); sf = (struct stack_frame *) (tsk->thread.ksp &PSW_ADDR_INSN );if (sf <= low || sf > high)return 0 ;