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=-5.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 BAD00C433E0 for ; Mon, 10 Aug 2020 12:44:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7CAC3206C3 for ; Mon, 10 Aug 2020 12:44:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="rUgIUgpg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CAC3206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F3D056B0005; Mon, 10 Aug 2020 08:44:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEE798D0001; Mon, 10 Aug 2020 08:44:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8D966B0007; Mon, 10 Aug 2020 08:44:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id BF5406B0005 for ; Mon, 10 Aug 2020 08:44:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 453BE181AEF00 for ; Mon, 10 Aug 2020 12:44:40 +0000 (UTC) X-FDA: 77134627920.11.plane25_380a67526fda Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 17260180F8B81 for ; Mon, 10 Aug 2020 12:44:40 +0000 (UTC) X-HE-Tag: plane25_380a67526fda X-Filterd-Recvd-Size: 7893 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Mon, 10 Aug 2020 12:44:39 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id t23so6565426qto.3 for ; Mon, 10 Aug 2020 05:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=gAr4D/ePrFPzg5ITCo7F2eiZjjapefZpMToAlkphjvI=; b=rUgIUgpgGYUj+dAL7OY+LRW5B1iNfQaizOTu9QModP4rJmLpbj0zM8gSoW2w1gF1gY zJV8PNKkE6NtgSi2X3vVTIBw/spdtf7mf7l9OcqJ3uA+1MZ72PhMp3lhE+yX+35/6sKm 2BXOKptXGfmHSiMh9t93c6NwQX6CX8nkh7+lXAUa2XI8pLhB0IyVbvrXRpeBmlyGd86M orq/baff+/CDquuUn8Tt53OsDBxzd8zRTB2ioMuODI0kfd0ZnVPsoFuHJT2QU09M2CEj R60Lg3qbqsLE70u2+kBwOqcWgpANqUVqEkqWPi+87reEyhb5ukrem2Y8FB0qlr/gmCwE ABqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=gAr4D/ePrFPzg5ITCo7F2eiZjjapefZpMToAlkphjvI=; b=eI6w9kV9EadNlXhChYCWnGtv9QTC/9wvuWUF35M0H8Se6n6PH3evhZpUMqgxz1JO+f wbicudxR0up1fslYQjavFN3+7A8JR2yeG2/OpA3/zfDtjFaqFbupN2dpLYnJSlgsju+Q PTtpz7Q2mJyrWH77aaKspOpQQtJvcAZsi6jR+eKnM02dN1e2U0gnPYWf5WfqX3fOc3nO MRvM4PIcqHkJhRKKMF/57H7eCLQ1Nxe/42Ix9J0KgxfTs1cDuyAP8QkWPZq8Wfn2jk96 XiDI5qeFevu20YSr4xo9985k8BgEy5uazLREm4pv7gX/AGJTc8SCxviGnUunCajSsfve QXIQ== X-Gm-Message-State: AOAM532eXA+fKg7MzAQinMsws5l5Zl85Ax4Ei/fDB+1HcSbaFjvMezj4 R2NO/iVWJ1yYfzfETZwiwLnGsw== X-Google-Smtp-Source: ABdhPJzs2CqjFarg0XkEZgbuZmZNab5q0MHr7iwix6stb9A6MtLvWHu783qEEPSn0NIzKfkEUxh6CA== X-Received: by 2002:ac8:47c8:: with SMTP id d8mr25413219qtr.32.1597063478706; Mon, 10 Aug 2020 05:44:38 -0700 (PDT) Received: from lca.pw (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id l1sm15330349qtp.96.2020.08.10.05.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 05:44:38 -0700 (PDT) Date: Mon, 10 Aug 2020 08:44:31 -0400 From: Qian Cai To: Walter Wu Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , John Stultz , Stephen Boyd , Andrew Morton , Tejun Heo , Lai Jiangshan , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wsd_upstream , linux-mediatek@lists.infradead.org Subject: Re: [PATCH 0/5] kasan: add workqueue and timer stack for generic KASAN Message-ID: <20200810124430.GA5307@lca.pw> References: <20200810072115.429-1-walter-zh.wu@mediatek.com> <1597060257.13160.11.camel@mtksdccf07> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1597060257.13160.11.camel@mtksdccf07> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 17260180F8B81 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Aug 10, 2020 at 07:50:57PM +0800, Walter Wu wrote: > On Mon, 2020-08-10 at 07:19 -0400, Qian Cai wrote: > >=20 > > > On Aug 10, 2020, at 3:21 AM, Walter Wu = wrote: > > >=20 > > > =EF=BB=BFSyzbot reports many UAF issues for workqueue or timer, see= [1] and [2]. > > > In some of these access/allocation happened in process_one_work(), > > > we see the free stack is useless in KASAN report, it doesn't help > > > programmers to solve UAF on workqueue. The same may stand for times= . > > >=20 > > > This patchset improves KASAN reports by making them to have workque= ue > > > queueing stack and timer queueing stack information. It is useful f= or > > > programmers to solve use-after-free or double-free memory issue. > > >=20 > > > Generic KASAN will record the last two workqueue and timer stacks, > > > print them in KASAN report. It is only suitable for generic KASAN. > > >=20 > > > In order to print the last two workqueue and timer stacks, so that > > > we add new members in struct kasan_alloc_meta. > > > - two workqueue queueing work stacks, total size is 8 bytes. > > > - two timer queueing stacks, total size is 8 bytes. > > >=20 > > > Orignial struct kasan_alloc_meta size is 16 bytes. After add new > > > members, then the struct kasan_alloc_meta total size is 32 bytes, > > > It is a good number of alignment. Let it get better memory consumpt= ion. > >=20 > > Getting debugging tools complicated surely is the best way to kill it= . I would argue that it only make sense to complicate it if it is useful = most of the time which I never feel or hear that is the case. This remind= s me your recent call_rcu() stacks that most of time just makes parsing t= he report cumbersome. Thus, I urge this exercise to over-engineer on spec= ial cases need to stop entirely. > >=20 >=20 > A good debug tool is to have complete information in order to solve > issue. We should focus on if KASAN reports always show this debug > information or create a option to decide if show it. Because this > feature is Dimitry's suggestion. see [1]. So I think it need to be > implemented. Maybe we can wait his response.=20 >=20 > [1]https://lkml.org/lkml/2020/6/23/256 I don't know if it is Dmitry's pipe-dream which every KASAN report would = enable developers to fix it without reproducing it. It is always an ongoing stru= ggling between to make kernel easier to debug and the things less cumbersome. On the other hand, Dmitry's suggestion makes sense only if the price we a= re going to pay is fair. With the current diffstat and the recent experience= of call_rcu() stacks "waste" screen spaces as a heavy KASAN user myself, I c= an't really get that exciting for pushing the limit again at all. >=20 > Thanks. >=20 > > >=20 > > > [1]https://groups.google.com/g/syzkaller-bugs/search?q=3D%22use-aft= er-free%22+process_one_work > > > [2]https://groups.google.com/g/syzkaller-bugs/search?q=3D%22use-aft= er-free%22%20expire_timers > > > [3]https://bugzilla.kernel.org/show_bug.cgi?id=3D198437 > > >=20 > > > Walter Wu (5): > > > timer: kasan: record and print timer stack > > > workqueue: kasan: record and print workqueue stack > > > lib/test_kasan.c: add timer test case > > > lib/test_kasan.c: add workqueue test case > > > kasan: update documentation for generic kasan > > >=20 > > > Documentation/dev-tools/kasan.rst | 4 ++-- > > > include/linux/kasan.h | 4 ++++ > > > kernel/time/timer.c | 2 ++ > > > kernel/workqueue.c | 3 +++ > > > lib/test_kasan.c | 54 ++++++++++++++++++++++++++++= ++++++++++++++++++++++++++ > > > mm/kasan/generic.c | 42 ++++++++++++++++++++++++++++= ++++++++++++++ > > > mm/kasan/kasan.h | 6 +++++- > > > mm/kasan/report.c | 22 ++++++++++++++++++++++ > > > 8 files changed, 134 insertions(+), 3 deletions(-) > > >=20 > > > --=20 > > > 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, s= end an email to kasan-dev+unsubscribe@googlegroups.com. > > > To view this discussion on the web visit https://groups.google.com/= d/msgid/kasan-dev/20200810072115.429-1-walter-zh.wu%40mediatek.com. >=20