From 962f0af83c239c0aef05639631e871c874b00f99 Mon Sep 17 00:00:00 2001 From: Gerald Schaefer Date: Mon, 27 May 2019 18:40:19 +0200 Subject: s390/mm: fix address space detection in exception handling Commit 0aaba41b58bc ("s390: remove all code using the access register mode") removed access register mode from the kernel, and also from the address space detection logic. However, user space could still switch to access register mode (trans_exc_code == 1), and exceptions in that mode would not be correctly assigned. Fix this by adding a check for trans_exc_code == 1 to get_fault_type(), and remove the wrong comment line before that function. Fixes: 0aaba41b58bc ("s390: remove all code using the access register mode") Reviewed-by: Janosch Frank Reviewed-by: Heiko Carstens Cc: # v4.15+ Signed-off-by: Gerald Schaefer Signed-off-by: Heiko Carstens --- arch/s390/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 91ce03fd0c84..df75d574246d 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -83,7 +83,6 @@ static inline int notify_page_fault(struct pt_regs *regs) /* * Find out which address space caused the exception. - * Access register mode is impossible, ignore space == 3. */ static enum fault_type get_fault_type(struct pt_regs *regs) { @@ -108,6 +107,10 @@ static enum fault_type get_fault_type(struct pt_regs *regs) } return VDSO_FAULT; } + if (trans_exc_code == 1) { + /* access register mode, not used in the kernel */ + return USER_FAULT; + } /* home space exception -> access via kernel ASCE */ return KERNEL_FAULT; } -- cgit v1.2.3 From 0ab0d7ac2090eae30f1c0b01ae981bb7a368f598 Mon Sep 17 00:00:00 2001 From: Vasily Gorbik Date: Thu, 6 Jun 2019 16:58:45 +0200 Subject: s390/unwind: correct stack switching during unwind Adjust conditions in on_stack function. That fixes backchain unwinder which was unable to read pt_regs at the very bottom of the stack and hence couldn't follow stacks (e.g. from async stack to a task stack). Fixes: 78c98f907413 ("s390/unwind: introduce stack unwind API") Reported-by: Julian Wiedmann Reviewed-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Heiko Carstens --- arch/s390/include/asm/stacktrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/s390/include/asm/stacktrace.h b/arch/s390/include/asm/stacktrace.h index 49634bfbecdd..0ae4bbf7779c 100644 --- a/arch/s390/include/asm/stacktrace.h +++ b/arch/s390/include/asm/stacktrace.h @@ -30,7 +30,7 @@ static inline bool on_stack(struct stack_info *info, return false; if (addr + len < addr) return false; - return addr >= info->begin && addr + len < info->end; + return addr >= info->begin && addr + len <= info->end; } static inline unsigned long get_stack_pointer(struct task_struct *task, -- cgit v1.2.3