* [PATCH 02/11] signal/sh: Ensure si_signo is initialized in do_divide_error [not found] <87373b6ghs.fsf@xmission.com> @ 2018-01-12 0:59 ` Eric W. Biederman 2018-01-12 0:59 ` [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal Eric W. Biederman 1 sibling, 0 replies; 4+ messages in thread From: Eric W. Biederman @ 2018-01-12 0:59 UTC (permalink / raw) To: linux-kernel Cc: Al Viro, Oleg Nesterov, linux-arch, Eric W. Biederman, Yoshinori Sato, Rich Felker, Paul Mundt, linux-sh, stable Set si_signo. Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Rich Felker <dalias@libc.org> Cc: Paul Mundt <lethal@linux-sh.org> Cc: linux-sh@vger.kernel.org Cc: stable@vger.kernel.org Fixes: 0983b31849bb ("sh: Wire up division and address error exceptions on SH-2A.") Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> --- arch/sh/kernel/traps_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c index 57cff00cad17..b3770bb26211 100644 --- a/arch/sh/kernel/traps_32.c +++ b/arch/sh/kernel/traps_32.c @@ -609,7 +609,8 @@ asmlinkage void do_divide_error(unsigned long r4) break; } - force_sig_info(SIGFPE, &info, current); + info.si_signo = SIGFPE; + force_sig_info(info.si_signo, &info, current); } #endif -- 2.14.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal [not found] <87373b6ghs.fsf@xmission.com> 2018-01-12 0:59 ` [PATCH 02/11] signal/sh: Ensure si_signo is initialized in do_divide_error Eric W. Biederman @ 2018-01-12 0:59 ` Eric W. Biederman 2018-01-12 13:25 ` Stafford Horne 1 sibling, 1 reply; 4+ messages in thread From: Eric W. Biederman @ 2018-01-12 0:59 UTC (permalink / raw) To: linux-kernel Cc: Al Viro, Oleg Nesterov, linux-arch, Eric W. Biederman, stable, Jonas Bonn, Stefan Kristiansson, Stafford Horne, Arnd Bergmann, openrisc 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. Cc: stable@vger.kernel.org Fixes: 769a8a96229e ("OpenRISC: Traps") Cc: Jonas Bonn <jonas@southpole.se> Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Cc: Stafford Horne <shorne@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: openrisc@lists.librecores.org Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> --- 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal 2018-01-12 0:59 ` [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal Eric W. Biederman @ 2018-01-12 13:25 ` Stafford Horne 2018-01-12 17:37 ` Eric W. Biederman 0 siblings, 1 reply; 4+ messages in thread From: Stafford Horne @ 2018-01-12 13:25 UTC (permalink / raw) To: Eric W. Biederman Cc: linux-kernel, Al Viro, Oleg Nesterov, linux-arch, stable, Jonas Bonn, Stefan Kristiansson, Arnd Bergmann, openrisc 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 <shorne@gmail.com> 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 <jonas@southpole.se> > Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> > Cc: Stafford Horne <shorne@gmail.com> > Cc: Arnd Bergmann <arnd@arndb.de> > Cc: openrisc@lists.librecores.org > Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> > --- > 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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal 2018-01-12 13:25 ` Stafford Horne @ 2018-01-12 17:37 ` Eric W. Biederman 0 siblings, 0 replies; 4+ messages in thread From: Eric W. Biederman @ 2018-01-12 17:37 UTC (permalink / raw) To: Stafford Horne Cc: linux-kernel, Al Viro, Oleg Nesterov, linux-arch, stable, Jonas Bonn, Stefan Kristiansson, Arnd Bergmann, openrisc Stafford Horne <shorne@gmail.com> writes: > 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 <shorne@gmail.com> > > 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. Yes, I have a follow on patch that restructures the code that fills out siginfo, and makes the it a little less error prone. I am hoping to merge all of it in the next merge window. *Fingers crossed* And having it all in one tree will facilitate that. > 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 */ > It looks like it. When I look at those I can actually find the si_code being set higher up in the code. It looks like the si_code value was missed when this work was done. Eric ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-12 17:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <87373b6ghs.fsf@xmission.com>
2018-01-12 0:59 ` [PATCH 02/11] signal/sh: Ensure si_signo is initialized in do_divide_error Eric W. Biederman
2018-01-12 0:59 ` [PATCH 03/11] signal/openrisc: Fix do_unaligned_access to send the proper signal Eric W. Biederman
2018-01-12 13:25 ` Stafford Horne
2018-01-12 17:37 ` Eric W. Biederman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).