Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933816AbeALNZ3 (ORCPT + 1 other); Fri, 12 Jan 2018 08:25:29 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35067 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933769AbeALNZZ (ORCPT ); Fri, 12 Jan 2018 08:25:25 -0500 X-Google-Smtp-Source: ACJfBotnses8i3073nwJ7yH1HG+uznJKal9ypsyoKN10X3PsyPmu48bUrEt4XBmkd96QYZGNd9hlWQ== Date: Fri, 12 Jan 2018 22:25:21 +0900 From: Stafford Horne To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Al Viro , Oleg Nesterov , linux-arch@vger.kernel.org, stable@vger.kernel.org, Jonas Bonn , Stefan Kristiansson , Arnd Bergmann , openrisc@lists.librecores.org Subject: Re: [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal Message-ID: <20180112132521.GF13019@lianli.shorne-pla.net> References: <87373b6ghs.fsf@xmission.com> <20180112005940.23279-3-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180112005940.23279-3-ebiederm@xmission.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 11, 2018 at 06:59:32PM -0600, Eric W. Biederman wrote: > While reviewing the signal sending on openrisc the do_unaligned_access > function stood out because it is obviously wrong. A comment about an > si_code set above when actually si_code is never set. Leading to a > random si_code being sent to userspace in the event of an unaligned > access. > > Looking further SIGBUS BUS_ADRALN is the proper pair of signal and > si_code to send for an unaligned access. That is what other > architectures do and what is required by posix. > > Given that do_unaligned_access is broken in a way that no one can be > relying on it on openrisc fix the code to just do the right thing. Thanks, this looks good to me. Acked-by: Stafford Horne I see you have a series of related issues, so I guess you want to get them merged together. Let me know if I should put this patch onto my queue seperately. Trivia: this looks to have been copied from the mm page fault handling code, hence the strange comment. $ grep -r "info.si_code has been set above" arch/ arch/cris/mm/fault.c: /* info.si_code has been set above */ arch/m32r/mm/fault.c: /* info.si_code has been set above */ arch/mn10300/mm/fault.c: /* info.si_code has been set above */ arch/openrisc/mm/fault.c: /* info.si_code has been set above */ arch/openrisc/kernel/traps.c: /* info.si_code has been set above */ arch/arc/mm/fault.c: /* info.si_code has been set above */ arch/xtensa/mm/fault.c: /* info.si_code has been set above */ arch/mips/mm/fault.c: /* info.si_code has been set above */ arch/score/mm/fault.c: /* info.si_code has been set above */ arch/frv/mm/fault.c: /* info.si_code has been set above */ -Stafford > Cc: stable@vger.kernel.org > Fixes: 769a8a96229e ("OpenRISC: Traps") > Cc: Jonas Bonn > Cc: Stefan Kristiansson > Cc: Stafford Horne > Cc: Arnd Bergmann > Cc: openrisc@lists.librecores.org > Signed-off-by: "Eric W. Biederman" > --- > arch/openrisc/kernel/traps.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c > index 4085d72fa5ae..9e38dc66c9e4 100644 > --- a/arch/openrisc/kernel/traps.c > +++ b/arch/openrisc/kernel/traps.c > @@ -266,12 +266,12 @@ asmlinkage void do_unaligned_access(struct pt_regs *regs, unsigned long address) > siginfo_t info; > > if (user_mode(regs)) { > - /* Send a SIGSEGV */ > - info.si_signo = SIGSEGV; > + /* Send a SIGBUS */ > + info.si_signo = SIGBUS; > info.si_errno = 0; > - /* info.si_code has been set above */ > - info.si_addr = (void *)address; > - force_sig_info(SIGSEGV, &info, current); > + info.si_code = BUS_ADRALN; > + info.si_addr = (void __user *)address; > + force_sig_info(SIGBUS, &info, current); > } else { > printk("KERNEL: Unaligned Access 0x%.8lx\n", address); > show_registers(regs); > -- > 2.14.1 >