From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A4C8C47255 for ; Mon, 11 May 2020 10:01:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 05F3120720 for ; Mon, 11 May 2020 10:01:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Fc1FlTQb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05F3120720 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 723E790001B; Mon, 11 May 2020 06:01:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D559900006; Mon, 11 May 2020 06:01:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59D0790001B; Mon, 11 May 2020 06:01:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 3F5B3900006 for ; Mon, 11 May 2020 06:01:28 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F0FE5E0BD for ; Mon, 11 May 2020 10:01:27 +0000 (UTC) X-FDA: 76803995814.30.north99_29d7ec303e830 X-HE-Tag: north99_29d7ec303e830 X-Filterd-Recvd-Size: 6111 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 May 2020 10:01:27 +0000 (UTC) Received: by mail-qv1-f66.google.com with SMTP id z9so2135254qvi.12 for ; Mon, 11 May 2020 03:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dEBQw3076mBvIY7CBwoK5uqpgbduOcTYtDKSbai7h/o=; b=Fc1FlTQbTssxu2TxqBIzl+6Xlu+t3hasOFsdn49nv21GLo9Z8aBGG/ltllQ5Mqv3vs /cS1DoIzzoA0etpn9Wb1dNWhoo4a7PnSU9gFA/dVQZkuny77X/CNk7hdQFyQxT8H3DVE EoV6Ku67L0CdgauG4BIN5MwiXPgC4FyhVfqLLtuUmawjRwNgqWpzTu0V3aeonSzSRMtL 8R9P8SURGv9c8w0VL0TDSiPfiUAE1V/xB68UPSMA7ViHFp2ND2ft3yukF1C5a44SZ8PL nkAwzrc+hrrENogaw8HqC+e+2No138vdOykTEcUxjE1xBWU0GiZOAnz+kfac1whzdwd7 J8OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dEBQw3076mBvIY7CBwoK5uqpgbduOcTYtDKSbai7h/o=; b=ZdIZdZrYCkr2BtRBq54v2N84f8ok8YlQkPIenPV13sPC73XvKigIq/jxXauxi9ZcXf aYaQZbMNM753u7+8hkRIp0cDQfdFoETrCR4ab9Bp9niI1WsbUbWHllwIywSs4qlg71Ao ijzOrHxiJ1VYkcCunQunbz/Nkhjhzg5VBUoEO50mJskrcVPRBBvQ64FqlRHbUEZWwT4U 0vs5fH87g1W7QqtHo91YOVvCvYZGvgNhmqQVvkzYDHfOC3mB10SrjChWmj8r7wLqte10 ppCEuL7L7sLzyI1ITI6+0B6qy/ruDIAu3m1vwCWEYohW0zsaLN4e5NdK6TqY4zarcp+m QslQ== X-Gm-Message-State: AGi0PuadBwIhsZFzzzjY5F00qXJWMVOTdDVw509iPq/LUWvtCwunWYtd YpiaiUXm+cMuzh/KK5zXefom1RDnFBq0rZxXV9J7gA== X-Google-Smtp-Source: APiQypK3J4Uss9hZs4ShXGbm1QYq+YrrdMGKWDeQyyrRLVZFWF+P7Ohh0VDwlQa19CWjtVyUyFUBSpLqPPKQVLzi6XA= X-Received: by 2002:ad4:5a48:: with SMTP id ej8mr15299087qvb.122.1589191286510; Mon, 11 May 2020 03:01:26 -0700 (PDT) MIME-Version: 1.0 References: <20200511022359.15063-1-walter-zh.wu@mediatek.com> In-Reply-To: <20200511022359.15063-1-walter-zh.wu@mediatek.com> From: Dmitry Vyukov Date: Mon, 11 May 2020 12:01:14 +0200 Message-ID: Subject: Re: [PATCH v2 0/3] kasan: memorize and print call_rcu stack To: Walter Wu Cc: Andrey Ryabinin , Alexander Potapenko , Matthias Brugger , "Paul E . McKenney" , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , Andrew Morton , kasan-dev , Linux-MM , LKML , Linux ARM , wsd_upstream , linux-mediatek@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, May 11, 2020 at 4:24 AM Walter Wu wrote: > > 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. Hi Walter, I am looking at this now. I've upload the change to gerrit [1] https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/2458 I am not capable enough to meaningfully review such changes in this format... [1] https://linux.googlesource.com/Documentation > 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(-) > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20200511022359.15063-1-walter-zh.wu%40mediatek.com.