All of lore.kernel.org
 help / color / mirror / Atom feed
From: kamensky@cisco.com (Victor Kamensky)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: mm: unaligned access by user-land should be received as SIGBUS
Date: Sun,  2 Apr 2017 22:45:14 -0700	[thread overview]
Message-ID: <1491198314-17025-2-git-send-email-kamensky@cisco.com> (raw)
In-Reply-To: <1491198314-17025-1-git-send-email-kamensky@cisco.com>

After 52d7523 (arm64: mm: allow the kernel to handle alignment faults on
user accesses) commit user-land accesses that produce unaligned exceptions
like in case of aarch32 ldm/stm/ldrd/strd instructions operating on
unaligned memory received by user-land as SIGSEGV. It is wrong, it should
be reported as SIGBUS as it was before 52d7523 commit.

Changed do_bad_area function to take signal and code parameters, so caller
can pass them down properly depending on fault type, as SIGSEGV in case of
do_translation_fault and SIGBUS in case of do_alignment_fault.

Signed-off-by: Victor Kamensky <kamensky@cisco.com>
Cc: xe-linux-external at cisco.com
Fixes: 52d7523 (arm64: mm: allow the kernel to handle alignment faults on user accesses)
---
 arch/arm64/mm/fault.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 4bf899f..204eb58 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -215,7 +215,8 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr,
 	force_sig_info(sig, &si, tsk);
 }
 
-static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
+static void do_bad_area(unsigned long addr, unsigned int esr,
+			struct pt_regs *regs, int sig, int code)
 {
 	struct task_struct *tsk = current;
 	struct mm_struct *mm = tsk->active_mm;
@@ -225,7 +226,7 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
 	 * handle this fault with.
 	 */
 	if (user_mode(regs))
-		__do_user_fault(tsk, addr, esr, SIGSEGV, SEGV_MAPERR, regs);
+		__do_user_fault(tsk, addr, esr, sig, code, regs);
 	else
 		__do_kernel_fault(mm, addr, esr, regs);
 }
@@ -469,14 +470,14 @@ static int __kprobes do_translation_fault(unsigned long addr,
 	if (addr < TASK_SIZE)
 		return do_page_fault(addr, esr, regs);
 
-	do_bad_area(addr, esr, regs);
+	do_bad_area(addr, esr, regs, SIGSEGV, SEGV_MAPERR);
 	return 0;
 }
 
 static int do_alignment_fault(unsigned long addr, unsigned int esr,
 			      struct pt_regs *regs)
 {
-	do_bad_area(addr, esr, regs);
+	do_bad_area(addr, esr, regs, SIGBUS,  BUS_ADRALN);
 	return 0;
 }
 
-- 
1.9.3

  reply	other threads:[~2017-04-03  5:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03  5:45 [PATCH] fix armv8 kernel generation of SIGSEGV upon unaligned access Victor Kamensky
2017-04-03  5:45 ` Victor Kamensky [this message]
2017-04-03  9:24   ` [PATCH] arm64: mm: unaligned access by user-land should be received as SIGBUS Will Deacon
2017-04-06  6:01     ` Victor Kamensky
2017-04-06  8:44       ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491198314-17025-2-git-send-email-kamensky@cisco.com \
    --to=kamensky@cisco.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.