From: Walter Wu <walter-zh.wu@mediatek.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Joel Fernandes <joel@joelfernandes.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: <kasan-dev@googlegroups.com>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
wsd_upstream <wsd_upstream@mediatek.com>,
<linux-mediatek@lists.infradead.org>,
Walter Wu <walter-zh.wu@mediatek.com>
Subject: [PATCH v2 0/3] kasan: memorize and print call_rcu stack
Date: Mon, 11 May 2020 10:23:59 +0800 [thread overview]
Message-ID: <20200511022359.15063-1-walter-zh.wu@mediatek.com> (raw)
This patchset improves KASAN reports by making them to have
call_rcu() call stack information. It is useful for programmers
to solve use-after-free or double-free memory issue.
The KASAN report was as follows(cleaned up slightly):
BUG: KASAN: use-after-free in kasan_rcu_reclaim+0x58/0x60
Freed by task 0:
save_stack+0x24/0x50
__kasan_slab_free+0x110/0x178
kasan_slab_free+0x10/0x18
kfree+0x98/0x270
kasan_rcu_reclaim+0x1c/0x60
rcu_core+0x8b4/0x10f8
rcu_core_si+0xc/0x18
efi_header_end+0x238/0xa6c
First call_rcu() call stack:
save_stack+0x24/0x50
kasan_record_callrcu+0xc8/0xd8
call_rcu+0x190/0x580
kasan_rcu_uaf+0x1d8/0x278
Last call_rcu() call stack:
(stack is not available)
Generic KASAN will record first and last call_rcu() call stack
and print two call_rcu() call stack in KASAN report.
This feature doesn't increase the cost of memory consumption. It is
only suitable for generic KASAN.
[1]https://bugzilla.kernel.org/show_bug.cgi?id=198437
[2]https://groups.google.com/forum/#!searchin/kasan-dev/better$20stack$20traces$20for$20rcu%7Csort:date/kasan-dev/KQsjT_88hDE/7rNUZprRBgAJ
Changes since v2:
- remove new config option, default enable it in generic KASAN
- test this feature in SLAB/SLUB, it is pass.
- modify macro to be more clearly
- modify documentation
Walter Wu (3):
rcu/kasan: record and print call_rcu() call stack
kasan: record and print the free track
kasan: update documentation for generic kasan
Documentation/dev-tools/kasan.rst | 6 ++++++
include/linux/kasan.h | 2 ++
kernel/rcu/tree.c | 4 ++++
lib/Kconfig.kasan | 2 ++
mm/kasan/common.c | 26 ++++----------------------
mm/kasan/generic.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
mm/kasan/kasan.h | 23 +++++++++++++++++++++++
mm/kasan/report.c | 47 +++++++++++++++++++++--------------------------
mm/kasan/tags.c | 37 +++++++++++++++++++++++++++++++++++++
9 files changed, 149 insertions(+), 48 deletions(-)
next reply other threads:[~2020-05-11 2:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 2:23 Walter Wu [this message]
2020-05-11 10:01 ` [PATCH v2 0/3] kasan: memorize and print call_rcu stack Dmitry Vyukov
2020-05-11 10:32 ` Walter Wu
2020-05-11 10:38 ` Dmitry Vyukov
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=20200511022359.15063-1-walter-zh.wu@mediatek.com \
--to=walter-zh.wu@mediatek.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=matthias.bgg@gmail.com \
--cc=paulmck@kernel.org \
--cc=wsd_upstream@mediatek.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).