From: Nylon Chen <nylon7@andestech.com>
To: <aryabinin@virtuozzo.com>, <glider@google.com>,
<dvyukov@google.com>, <kasan-dev@googlegroups.com>,
<akpm@linux-foundation.org>, <paul.walmsley@sifive.com>,
<palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<nickhu@andestech.com>, <nylon7@andestech.com>,
<luc.vanoostenryck@gmail.com>, <greentime.hu@sifive.com>,
<linux-riscv@lists.infradead.org>
Cc: nylon7717@gmail.com, Nick Hu <nick650823@gmail.com>,
alankao@andestech.com
Subject: [PATCH 0/1] Fix Kasan test module run failed in RISCV architecture
Date: Mon, 30 Nov 2020 17:13:18 +0800 [thread overview]
Message-ID: <1606727599-8598-1-git-send-email-nylon7@andestech.com> (raw)
When you run Kasan test module in RISCV architecture,"kmalloc_memmove_invalid_size()"
will be executed and then kernel will be hang in infinite loop as below:
[ 26.228433] Memory state around the buggy address:
[ 26.229824] ffffffe066e11d00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[ 26.232098] ffffffe066e11d80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[ 26.234461] >ffffffe066e11e00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[ 26.236650] ^
[ 26.238149] ffffffe066e11e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 26.240400] ffffffe066e11f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 26.242646]
==================================================================
[ 26.245312]
==================================================================
[ 26.247607] BUG: KASAN: slab-out-of-bounds in memmove+0x2e/0x8a
[ 26.249160] Read of size 1 at addr ffffffe066e11e49 by task
insmod/106
[ 26.250855]
[ 26.251755] CPU: 0 PID: 106 Comm: insmod Tainted: G B
5.8.7 #2
[ 26.253454] Call Trace:
[ 26.254509] [<ffffffe000203256>] walk_stackframe+0x0/0x128
[ 26.256027] [<ffffffe000203530>] show_stack+0x2e/0x3a
[ 26.257467] [<ffffffe0005ab9e0>] dump_stack+0x84/0xa0
[ 26.258936] [<ffffffe000367120>]
print_address_description.isra.0+0x34/0x404
[ 26.260686] [<ffffffe000367676>] kasan_report+0xda/0x132
[ 26.262141] [<ffffffe000367a68>] __asan_load1+0x42/0x4a
[ 26.263610] [<ffffffe0005c1c4c>] memmove+0x2e/0x8a
[ 26.265241] [<ffffffdf81cdec26>]
kmalloc_memmove_invalid_size+0x94/0xaa [test_kasan]
[ 26.267829] [<ffffffdf81cdfa2a>] kmalloc_tests_init+0x94/0x14a
[test_kasan]
[ 26.269563] [<ffffffe0002000d8>] do_one_initcall+0x40/0x134
[ 26.271106] [<ffffffe0002a2e5c>] do_init_module+0xc6/0x25c
[ 26.272610] [<ffffffe0002a5692>] load_module+0x257a/0x2bf2
[ 26.274096] [<ffffffe0002a5e70>] __do_sys_finit_module+0x7e/0x94
[ 26.275676] [<ffffffe0002a5eaa>] sys_finit_module+0x10/0x18
[ 26.277207] [<ffffffe000201690>] ret_from_syscall+0x0/0x2
[ 26.278677]
.....
[ 579.407314] 0x0
[ 579.408267] 0x0
[ 579.409222] 0x0
[ 579.410198] 0x0
[ 579.411206] 0x0
[ 579.412151] 0x0
[ 579.413122] 0x0
[ 579.414080] 0x0
[ 579.415026] 0x0
[ 579.415964] 0x0
[ 579.416912] 0x0
[ 579.417871] 0x0
[ 579.418834] 0x0
[ 579.419781] 0x0
[ 579.420738] 0x0
[ 579.421841] 0x0
[ 579.422805] 0x0
[ 579.423764] 0x0
[ 579.424696] 0x0
[ 579.425638] 0x0
[ 579.426599] 0x0
[ 579.427538] 0x0
[ 579.428467] 0x0
.....
if we define __HAVE_ARCH_MEMMOVE and port memmove to RISCV can fix it.
Signed-off-by: Nick Hu <nickhu@andestech.com>
Signed-off-by: Nick Hu <nick650823@gmail.com>
Signed-off-by: Nylon Chen <nylon7@andestech.com>
Nylon Chen (1):
riscv: provide memmove implementation
arch/riscv/include/asm/string.h | 8 ++---
arch/riscv/kernel/riscv_ksyms.c | 2 ++
arch/riscv/lib/Makefile | 1 +
arch/riscv/lib/memmove.S | 64 +++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 arch/riscv/lib/memmove.S
--
2.17.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2020-11-30 9:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-30 9:13 Nylon Chen [this message]
2020-11-30 9:13 ` [PATCH 1/1] riscv: provide memmove implementation Nylon Chen
2020-12-11 1:43 ` Palmer Dabbelt
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=1606727599-8598-1-git-send-email-nylon7@andestech.com \
--to=nylon7@andestech.com \
--cc=akpm@linux-foundation.org \
--cc=alankao@andestech.com \
--cc=aou@eecs.berkeley.edu \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=greentime.hu@sifive.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-riscv@lists.infradead.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=nick650823@gmail.com \
--cc=nickhu@andestech.com \
--cc=nylon7717@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/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;
as well as URLs for NNTP newsgroup(s).