* [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct
@ 2011-07-27 12:10 Dave Martin
2011-07-27 14:13 ` Nicolas Pitre
2011-07-28 11:17 ` Kirill A. Shutemov
0 siblings, 2 replies; 3+ messages in thread
From: Dave Martin @ 2011-07-27 12:10 UTC (permalink / raw)
To: linux-arm-kernel
With the UM_SIGNAL alignment fault mode, no siginfo structure is
passed to userspace.
POSIX specifies how siginfo_t should be populated for alignment
faults, so this patch does just that:
* si_signo = SIGBUS
* si_code = BUS_ADRALN
* si_addr = misaligned data address at which access was attempted
Signed-off-by: Dave Martin <dave.martin@linaro.org>
---
v2: si_addr in siginfo_t changed to contain the faulting data
access address, not the address of the faulting instruction.
This behaviour is consistent with the way other fault signals
such as SIGSEGV are already reported, as well as matching the
apparent intent of the POSIX sigaction interface.
arch/arm/mm/alignment.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 724ba3b..65ed9c6 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -22,6 +22,7 @@
#include <linux/sched.h>
#include <linux/uaccess.h>
+#include <asm/system.h>
#include <asm/unaligned.h>
#include "fault.h"
@@ -883,9 +884,16 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
if (ai_usermode & UM_FIXUP)
goto fixup;
- if (ai_usermode & UM_SIGNAL)
- force_sig(SIGBUS, current);
- else {
+ if (ai_usermode & UM_SIGNAL) {
+ siginfo_t si;
+
+ si.si_signo = SIGBUS;
+ si.si_errno = 0;
+ si.si_code = BUS_ADRALN;
+ si.si_addr = (void __user *)addr;
+
+ force_sig_info(si.si_signo, &si, current);
+ } else {
/*
* We're about to disable the alignment trap and return to
* user space. But if an interrupt occurs before actually
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct
2011-07-27 12:10 [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Dave Martin
@ 2011-07-27 14:13 ` Nicolas Pitre
2011-07-28 11:17 ` Kirill A. Shutemov
1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2011-07-27 14:13 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 27 Jul 2011, Dave Martin wrote:
> With the UM_SIGNAL alignment fault mode, no siginfo structure is
> passed to userspace.
>
> POSIX specifies how siginfo_t should be populated for alignment
> faults, so this patch does just that:
>
> * si_signo = SIGBUS
> * si_code = BUS_ADRALN
> * si_addr = misaligned data address at which access was attempted
>
> Signed-off-by: Dave Martin <dave.martin@linaro.org>
> ---
> v2: si_addr in siginfo_t changed to contain the faulting data
> access address, not the address of the faulting instruction.
>
> This behaviour is consistent with the way other fault signals
> such as SIGSEGV are already reported, as well as matching the
> apparent intent of the POSIX sigaction interface.
Makes sense. ACK.
>
> arch/arm/mm/alignment.c | 14 +++++++++++---
> 1 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
> index 724ba3b..65ed9c6 100644
> --- a/arch/arm/mm/alignment.c
> +++ b/arch/arm/mm/alignment.c
> @@ -22,6 +22,7 @@
> #include <linux/sched.h>
> #include <linux/uaccess.h>
>
> +#include <asm/system.h>
> #include <asm/unaligned.h>
>
> #include "fault.h"
> @@ -883,9 +884,16 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
> if (ai_usermode & UM_FIXUP)
> goto fixup;
>
> - if (ai_usermode & UM_SIGNAL)
> - force_sig(SIGBUS, current);
> - else {
> + if (ai_usermode & UM_SIGNAL) {
> + siginfo_t si;
> +
> + si.si_signo = SIGBUS;
> + si.si_errno = 0;
> + si.si_code = BUS_ADRALN;
> + si.si_addr = (void __user *)addr;
> +
> + force_sig_info(si.si_signo, &si, current);
> + } else {
> /*
> * We're about to disable the alignment trap and return to
> * user space. But if an interrupt occurs before actually
> --
> 1.7.4.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct
2011-07-27 12:10 [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Dave Martin
2011-07-27 14:13 ` Nicolas Pitre
@ 2011-07-28 11:17 ` Kirill A. Shutemov
1 sibling, 0 replies; 3+ messages in thread
From: Kirill A. Shutemov @ 2011-07-28 11:17 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jul 27, 2011 at 01:10:36PM +0100, Dave Martin wrote:
> With the UM_SIGNAL alignment fault mode, no siginfo structure is
> passed to userspace.
>
> POSIX specifies how siginfo_t should be populated for alignment
> faults, so this patch does just that:
>
> * si_signo = SIGBUS
> * si_code = BUS_ADRALN
> * si_addr = misaligned data address at which access was attempted
>
> Signed-off-by: Dave Martin <dave.martin@linaro.org>
> ---
> v2: si_addr in siginfo_t changed to contain the faulting data
> access address, not the address of the faulting instruction.
>
> This behaviour is consistent with the way other fault signals
> such as SIGSEGV are already reported, as well as matching the
> apparent intent of the POSIX sigaction interface.
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-28 11:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-27 12:10 [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Dave Martin
2011-07-27 14:13 ` Nicolas Pitre
2011-07-28 11:17 ` Kirill A. Shutemov
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).