From: Michael Schmitz <schmitzmic@gmail.com>
To: linux-m68k@vger.kernel.org, geert@linux-m68k.org
Cc: gerg@linux-m68k.org, Michael Schmitz <schmitzmic@gmail.com>,
Finn Thain <fthain@linux-m68k.org>
Subject: [PATCH v3 2/2] m68k: improve __constant_copy_to_user_asm() fault handling
Date: Sat, 27 Apr 2024 20:48:15 +1200 [thread overview]
Message-ID: <20240427084815.1449-3-schmitzmic@gmail.com> (raw)
In-Reply-To: <20240427084815.1449-1-schmitzmic@gmail.com>
A problem similar to that reported for __put_user_asm and
__generic_copy_to_user is also present in
__constant_copy_to_user_asm.
Address the problem by extending the exception table to cover
two instructions past each moves instruction, and adding a
single NOP at the very end to catch faults on the final
instruction (which is not guaranteed to be a movesb!).
Tested on 68030 (Atari Falcon 030) with a transfer beginning
at a single byte at the end of a mapped page followed by
seven more bytes on an unmapped page (testcase derived from
stress-ng sysbadaddr stressor by Finn Thain and modified to
use the llseek syscall).
Cc: Finn Thain <fthain@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/all/e0f23460779e6d16e2633486ac4841790ef2aca0.1713176294.git.fthain@linux-m68k.org
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
arch/m68k/include/asm/uaccess.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/m68k/include/asm/uaccess.h b/arch/m68k/include/asm/uaccess.h
index 44e52d8323e5..f1f4b62d6f69 100644
--- a/arch/m68k/include/asm/uaccess.h
+++ b/arch/m68k/include/asm/uaccess.h
@@ -288,10 +288,11 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n)
"21: "MOVES"."#s2" %3,(%1)+\n" \
"22:\n" \
" .ifnc \""#s3"\",\"\"\n" \
- " move."#s3" (%2)+,%3\n" \
- "31: "MOVES"."#s3" %3,(%1)+\n" \
- "32:\n" \
+ "31: move."#s3" (%2)+,%3\n" \
+ "32: "MOVES"."#s3" %3,(%1)+\n" \
+ "33:\n" \
" .endif\n" \
+ "34: nop\n" \
"4:\n" \
"\n" \
" .section __ex_table,\"a\"\n" \
@@ -303,7 +304,9 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n)
" .ifnc \""#s3"\",\"\"\n" \
" .long 31b,5f\n" \
" .long 32b,5f\n" \
+ " .long 33b,5f\n" \
" .endif\n" \
+ " .long 34b,5f\n" \
" .previous\n" \
"\n" \
" .section .fixup,\"ax\"\n" \
--
2.17.1
next prev parent reply other threads:[~2024-04-27 8:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 8:48 [PATCH v3 0/2] m68k uaccess fault handling fixes Michael Schmitz
2024-04-27 8:48 ` [PATCH v3 1/2] m68k: Handle __generic_copy_to_user faults more carefully Michael Schmitz
2024-04-27 9:34 ` Finn Thain
2024-04-27 23:16 ` Michael Schmitz
2024-04-28 3:28 ` Finn Thain
2024-04-28 3:51 ` Michael Schmitz
2024-04-28 8:03 ` Finn Thain
2024-04-27 8:48 ` Michael Schmitz [this message]
2024-04-27 9:24 ` [PATCH v3 2/2] m68k: improve __constant_copy_to_user_asm() fault handling Finn Thain
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=20240427084815.1449-3-schmitzmic@gmail.com \
--to=schmitzmic@gmail.com \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=linux-m68k@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox