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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 BAB16C433DF for ; Mon, 25 May 2020 09:56:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7E35120812 for ; Mon, 25 May 2020 09:56:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jy+KUYg4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E35120812 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 1D2D58E0003; Mon, 25 May 2020 05:56:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A8BA8E0008; Mon, 25 May 2020 05:56:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EF0F8E0003; Mon, 25 May 2020 05:56:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id E7CB08E0003 for ; Mon, 25 May 2020 05:56:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A3849181AC9CC for ; Mon, 25 May 2020 09:56:54 +0000 (UTC) X-FDA: 76854787548.06.low56_59695a372fb5d X-HE-Tag: low56_59695a372fb5d X-Filterd-Recvd-Size: 5314 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 May 2020 09:56:54 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id f18so222076qkh.1 for ; Mon, 25 May 2020 02:56:54 -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=W3OPQj+6MaWJ3brcNW2aa4WZVKniXvFNcmel059rH8E=; b=Jy+KUYg4h6yqEgXZCmyC1r7hZaPjIJ5NbD8kOSB7ANDSGTcv/cxI7IqondbwUcYIx4 YDawj4yAqtGCTp0JhlLeUar5y5gF5ERMxMtMxT9kSvZxxMG4qNqP+DMsADzyMxnVKbjp Qp5JMPqDS0aZAK6jAL+ldHNC8V3WS0Ap82mFULselou6eQNZR6sUCTVknKoKe+7skkSe dQeDlVCIHtIQn2PZEtJqdGm5TlcgmE0EGSNqzldorS8mctTWozaYEL/goXdYZEUy6XHq b1ZewotnWXEtHoJ8G6kTfaYc7CdNtQvcQjiQnRuegORWPKpgBsNANNWjDA7f82Y4NWg5 MWzw== 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=W3OPQj+6MaWJ3brcNW2aa4WZVKniXvFNcmel059rH8E=; b=omWHFodXvLgvdH6f/4PJ1g5ov3HNVHhAXXGiAF9iX5mi14gB/hYMibMq51f3PT1ZKD /9MqTHy5siwt8vThJWn3Qny2KSH5ivGjHWSZmhSosnEiwqdcPDw8wb+288uLsWCQ4E62 l4s5GjA1ZYdoH/l2ibbl9U0E+1AdVtjSuUH9blFa46mMAj2nIG969q+cgaZY0bGfH02S +uZUYT5kGP8OZ4q5XS43QOUe3nGh+s/tHi4zq6dvGMaDPaLO+JHLhLisbNy3ZYzwqlmI O5Ow8g5ri9u0FE3HoTLCGzeetqZRxUhN+Rwt12/1+9im06l/85Lj9RMzYwoJZask6PfG epXg== X-Gm-Message-State: AOAM530Yvw/Br4Vc7apWLzjsRz9pX6s/P3gk5TcpHxdd7QWhlveC4DT9 x0lcsXWiMomQXxOhnVJJC9+vhV0eyaZEnzuRs/lzzw== X-Google-Smtp-Source: ABdhPJxqSbuF0F9MjNbi/qpdSowpX/KR1shgHH8LS5OI24MEwe9xv7ADZ1UvXqDFHd6kocEjU/m+KLakA52EHSzuhyQ= X-Received: by 2002:a05:620a:786:: with SMTP id 6mr1210763qka.407.1590400613522; Mon, 25 May 2020 02:56:53 -0700 (PDT) MIME-Version: 1.0 References: <20200522020151.23405-1-walter-zh.wu@mediatek.com> In-Reply-To: <20200522020151.23405-1-walter-zh.wu@mediatek.com> From: Dmitry Vyukov Date: Mon, 25 May 2020 11:56:42 +0200 Message-ID: Subject: Re: [PATCH v6 3/4] kasan: add tests for call_rcu stack recording To: Walter Wu Cc: Andrey Ryabinin , Alexander Potapenko , Matthias Brugger , 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 Fri, May 22, 2020 at 4:02 AM Walter Wu wrote: > > Test call_rcu() call stack recording and verify whether it correctly > is printed in KASAN report. Reviewed-and-tested-by: Dmitry Vyukov > Signed-off-by: Walter Wu > Cc: Andrey Ryabinin > Cc: Dmitry Vyukov > Cc: Alexander Potapenko > Cc: Matthias Brugger > --- > lib/test_kasan.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > index e3087d90e00d..6e5fb05d42d8 100644 > --- a/lib/test_kasan.c > +++ b/lib/test_kasan.c > @@ -792,6 +792,35 @@ static noinline void __init vmalloc_oob(void) > static void __init vmalloc_oob(void) {} > #endif > > +static struct kasan_rcu_info { > + int i; > + struct rcu_head rcu; > +} *global_ptr; > + > +static noinline void __init kasan_rcu_reclaim(struct rcu_head *rp) > +{ > + struct kasan_rcu_info *fp = container_of(rp, > + struct kasan_rcu_info, rcu); > + > + kfree(fp); > + fp->i = 1; > +} > + > +static noinline void __init kasan_rcu_uaf(void) > +{ > + struct kasan_rcu_info *ptr; > + > + pr_info("use-after-free in kasan_rcu_reclaim\n"); > + ptr = kmalloc(sizeof(struct kasan_rcu_info), GFP_KERNEL); > + if (!ptr) { > + pr_err("Allocation failed\n"); > + return; > + } > + > + global_ptr = rcu_dereference_protected(ptr, NULL); > + call_rcu(&global_ptr->rcu, kasan_rcu_reclaim); > +} > + > static int __init kmalloc_tests_init(void) > { > /* > @@ -839,6 +868,7 @@ static int __init kmalloc_tests_init(void) > kasan_bitops(); > kmalloc_double_kzfree(); > vmalloc_oob(); > + kasan_rcu_uaf(); > > kasan_restore_multi_shot(multishot); > > -- > 2.18.0 > > -- > 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/20200522020151.23405-1-walter-zh.wu%40mediatek.com.