From patchwork Tue Aug 25 01:57:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11734667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F674138A for ; Tue, 25 Aug 2020 01:58:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D0950204FD for ; Tue, 25 Aug 2020 01:58:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="LYPsrwgh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0950204FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1E8726B00BE; Mon, 24 Aug 2020 21:58:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 199076B00BF; Mon, 24 Aug 2020 21:58:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D7546B00C0; Mon, 24 Aug 2020 21:58:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id EC4616B00BE for ; Mon, 24 Aug 2020 21:58:01 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A73E58248047 for ; Tue, 25 Aug 2020 01:58:01 +0000 (UTC) X-FDA: 77187430362.03.level47_51150ae27058 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 7F57E28A4E8 for ; Tue, 25 Aug 2020 01:58:01 +0000 (UTC) X-Spam-Summary: 1,0,0,4895615b9e7d8659,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:541:800:960:966:968:973:988:989:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1534:1541:1585:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2731:2899:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:4250:4321:4385:5007:6261:6653:7875:8660:10004:10400:11026:11232:11473:11658:11914:12043:12048:12296:12297:12438:12521:12555:12895:13069:13148:13161:13229:13230:13311:13357:13972:14096:14097:14181:14394:14721:21080:21324:21451:21627:21740:21795:21939:30012:30029:30051:30054,0,RBL:210.61.82.183:@mediatek.com:.lbl8.mailshell.net-64.100.201.201 62.2.12.100;04yfq5u75ngyb93ks6kcomxxzzxogyppkwpkutnhn8q1zxpn3a3tqgs73ex6t7b.6g3157xnrpsaj9qazf7d89a6htrq1hkha3teaqxkswia5yzp9z6iifdwt7eec1o.q-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0, LFtime:5 X-HE-Tag: level47_51150ae27058 X-Filterd-Recvd-Size: 4729 Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 01:58:00 +0000 (UTC) X-UUID: ec1930a35c604ac492ce8b82d9c0679f-20200825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=r0Oq0tBfZ8jFMLMVK7p67PPtKlTRIAQp8x2ll2ZCeYU=; b=LYPsrwghAovTKnj/ZetTzL4lji/Z19ESHWJgRI7exMSlno0PdUfhIJTrpb3xeo7f0sL4ITKIPsZDpxzNK6afFU/LMDFxJE6tzzS9U2GX/1vYIgwU+gbtDe2gt2+nuCDZkayiVPyqMnMWL8Lt8GqLlx/Xv5fkiceCsxiFeQFnyNU=; X-UUID: ec1930a35c604ac492ce8b82d9c0679f-20200825 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 376347103; Tue, 25 Aug 2020 09:57:55 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Aug 2020 09:57:52 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Aug 2020 09:57:53 +0800 From: Walter Wu To: Marco Elver , Thomas Gleixner , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , John Stultz , Stephen Boyd , Andrew Morton CC: , , , , wsd_upstream , , Walter Wu Subject: [PATCH v3 1/6] timer: kasan: record timer stack Date: Tue, 25 Aug 2020 09:57:52 +0800 Message-ID: <20200825015752.27841-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Rspamd-Queue-Id: 7F57E28A4E8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: When analyze use-after-free or double-free issue, recording the timer stacks is helpful to to preserve usage history which potentially gives a hint about the affected code. Record the most recent two timer init calls in KASAN which are printed on failure in the KASAN report. For timers it has turned out to be useful to record the stack trace of the timer init call. Because if the UAF root cause is in timer init, then user can see KASAN report to get where it is registered and find out the root cause. It don't need to enable DEBUG_OBJECTS_TIMERS, but they have a chance to find out the root cause. Signed-off-by: Walter Wu Suggested-by: Marco Elver Suggested-by: Thomas Gleixner Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: John Stultz Cc: Thomas Gleixner Cc: Stephen Boyd --- v2: - Thanks for Marco and Thomas suggestion. - Remove unnecessary code and fix commit log - reuse kasan_record_aux_stack() and aux_stack to record timer and workqueue stack. --- kernel/time/timer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index a16764b0116e..1ed8f8aca7f5 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -796,6 +796,9 @@ static void do_init_timer(struct timer_list *timer, timer->function = func; timer->flags = flags | raw_smp_processor_id(); lockdep_init_map(&timer->lockdep_map, name, key, 0); + + /* record the timer stack in order to print it in KASAN report */ + kasan_record_aux_stack(timer); } /** From patchwork Tue Aug 25 01:58:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11734673 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E73D739 for ; Tue, 25 Aug 2020 01:58:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 01A1E20706 for ; Tue, 25 Aug 2020 01:58:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ehXeURId" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01A1E20706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 40C146B00BF; Mon, 24 Aug 2020 21:58:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3E2986B00C0; Mon, 24 Aug 2020 21:58:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FA138D0002; Mon, 24 Aug 2020 21:58:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 1BE0E6B00BF for ; Mon, 24 Aug 2020 21:58:42 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CB91C362B for ; Tue, 25 Aug 2020 01:58:41 +0000 (UTC) X-FDA: 77187432042.01.cup08_410919127058 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 97EA8100480B8 for ; Tue, 25 Aug 2020 01:58:41 +0000 (UTC) X-Spam-Summary: 1,0,0,eae1d9e082b466f4,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:541:800:960:966:968:973:988:989:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1534:1541:1585:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2731:2902:2907:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:4250:4385:5007:6261:6653:7514:7875:8660:9707:10004:10400:11026:11232:11658:11914:12048:12296:12297:12438:12521:12555:12895:13069:13148:13230:13311:13357:14096:14097:14181:14394:14721:21080:21324:21451:21627:21740:21795:21939:30012:30051:30054,0,RBL:210.61.82.184:@mediatek.com:.lbl8.mailshell.net-62.2.12.100 64.100.201.201;04ygqybbem17zibp7znrnjqowmz9topueotxjy7nuztdo8g148owd4g68fu7t78.ndkbd8sd4zq6k63icriutzashtamujq85anou6ro78eed3urymoi3rzdtwkx8gj.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: cup08_410919127058 X-Filterd-Recvd-Size: 4346 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 01:58:40 +0000 (UTC) X-UUID: 0684c9f2029942189b2e2ebe3781934f-20200825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=QjiWiguuQ5aBJrBkNVTbpiMEZNHatuVj+uLpNS9djNY=; b=ehXeURId29jpQwQ+ZBXw/aE0Sx6qzqnI0kGiCDJQgGvFCGUFEJw7UKTWqM7u2sOYEadt1fWoTG+ST9Rz8+RGH7hvcSKRYhFo1ZPhJBxO3F9UiBoka78DDFNh46aNU6JYcMoT6Kt5ucQ2C3pcdEpIj1yURDmT3xYzOZeuPkHeHnk=; X-UUID: 0684c9f2029942189b2e2ebe3781934f-20200825 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1742342722; Tue, 25 Aug 2020 09:58:36 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Aug 2020 09:58:34 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Aug 2020 09:58:35 +0800 From: Walter Wu To: Marco Elver , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , Andrew Morton , Tejun Heo , Lai Jiangshan CC: , , , , wsd_upstream , , Walter Wu Subject: [PATCH v3 2/6] workqueue: kasan: record workqueue stack Date: Tue, 25 Aug 2020 09:58:33 +0800 Message-ID: <20200825015833.27900-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Rspamd-Queue-Id: 97EA8100480B8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: Records the last two enqueuing work call stacks in order to print them in KASAN report. It is useful for programmers to solve use-after-free or double-free memory workqueue issue. For workqueue it has turned out to be useful to record the enqueuing work call stacks. Because user can see KASAN report to determine whether it is root cause. They don't need to enable debugobjects, but they have a chance to find out the root cause. Signed-off-by: Walter Wu Suggested-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Tejun Heo Cc: Lai Jiangshan Acked-by: Tejun Heo --- v2: - Thanks for Marco suggestion. - Remove unnecessary code - reuse kasan_record_aux_stack() and aux_stack to record timer and workqueue stack --- kernel/workqueue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c41c3c17b86a..5fea7dc9180f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1324,6 +1324,9 @@ static void insert_work(struct pool_workqueue *pwq, struct work_struct *work, { struct worker_pool *pool = pwq->pool; + /* record the work call stack in order to print it in KASAN reports */ + kasan_record_aux_stack(work); + /* we own @work, set data and link */ set_work_pwq(work, pwq, extra_flags); list_add_tail(&work->entry, head); From patchwork Tue Aug 25 01:59:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11734679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B72F4739 for ; Tue, 25 Aug 2020 01:59:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8521D204EC for ; Tue, 25 Aug 2020 01:59:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="CkY8+fD9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8521D204EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D0DAA6B00C1; Mon, 24 Aug 2020 21:59:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CE4406B00C2; Mon, 24 Aug 2020 21:59:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF9F96B00C3; Mon, 24 Aug 2020 21:59:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AB0156B00C1 for ; Mon, 24 Aug 2020 21:59:20 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 64662180AD801 for ; Tue, 25 Aug 2020 01:59:20 +0000 (UTC) X-FDA: 77187433680.27.bone50_2714e4427058 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id E73243D66D for ; Tue, 25 Aug 2020 01:59:15 +0000 (UTC) X-Spam-Summary: 1,0,0,89ceef6db6692f61,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1534:1541:1585:1711:1730:1747:1777:1792:1981:2194:2198:2199:2200:2393:2559:2562:2731:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3874:4250:5007:6261:6653:7875:8660:9707:10004:10400:11026:11232:11473:11658:11914:12043:12048:12296:12297:12438:12521:12555:12895:13069:13148:13161:13229:13230:13311:13357:14181:14394:14721:21080:21451:21627:21740:21939:30029:30054:30070,0,RBL:210.61.82.184:@mediatek.com:.lbl8.mailshell.net-62.2.12.100 64.100.201.201;04yrf98h667r4i13mtx56nnfbeizqoconke5x1jhkxt6pq1cg15sexg7d1tya1o.wgwfq86aka5qb91i591wk5ah6gbemy6z3dwdk1uoofsn56m9rehuqua1oyitcwz.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:27,LUA_SUMMARY:none X-HE-Tag: bone50_2714e4427058 X-Filterd-Recvd-Size: 4051 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 01:59:14 +0000 (UTC) X-UUID: 21ea5009868a412fbc725ab180ae487e-20200825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=HDzXMXMz+Dzcg9DxfMTu2qwgwLYa3ujPve0aUqFM/KA=; b=CkY8+fD91Y9Ppm4YktSKuklZvE9EhtNf0Jh+t/uJj4TSZUSbDZteRMrgYyy+ErGHI6Xh+Q7rpiF+caZO4Jua+9w4sDvDoFGfj6j2dP/iHHO+yZkIoTLkdQ8lhaHNFA3scyvTAULE32u8VT4kTR6WHiZGkAyCdOowtNAZ9kIUCnU=; X-UUID: 21ea5009868a412fbc725ab180ae487e-20200825 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1002895838; Tue, 25 Aug 2020 09:59:09 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Aug 2020 09:59:03 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Aug 2020 09:59:04 +0800 From: Walter Wu To: Marco Elver , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger CC: , , , , wsd_upstream , , Walter Wu Subject: [PATCH v3 3/6] kasan: print timer and workqueue stack Date: Tue, 25 Aug 2020 09:59:02 +0800 Message-ID: <20200825015902.27951-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Rspamd-Queue-Id: E73243D66D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.002189, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The aux_stack[2] is reused to record the call_rcu() call stack, timer init call stack, and enqueuing work call stacks. So that we need to change the auxiliary stack title for common title, print them in KASAN report. Signed-off-by: Walter Wu Suggested-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko --- v2: - Thanks for Marco suggestion. - We modify aux stack title name in KASAN report in order to print call_rcu()/timer/workqueue stack. --- mm/kasan/report.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 4f49fa6cd1aa..886809d0a8dd 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -183,12 +183,12 @@ static void describe_object(struct kmem_cache *cache, void *object, #ifdef CONFIG_KASAN_GENERIC if (alloc_info->aux_stack[0]) { - pr_err("Last call_rcu():\n"); + pr_err("Last potentially related work creation:\n"); print_stack(alloc_info->aux_stack[0]); pr_err("\n"); } if (alloc_info->aux_stack[1]) { - pr_err("Second to last call_rcu():\n"); + pr_err("Second to last potentially related work creation:\n"); print_stack(alloc_info->aux_stack[1]); pr_err("\n"); } From patchwork Tue Aug 25 01:59:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11734685 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80027739 for ; Tue, 25 Aug 2020 01:59:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D25E204EC for ; Tue, 25 Aug 2020 01:59:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="AEwEMb9K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D25E204EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 82BDA6B00C2; Mon, 24 Aug 2020 21:59:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 802358D0002; Mon, 24 Aug 2020 21:59:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 718136B00C4; Mon, 24 Aug 2020 21:59:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 5B4E66B00C2 for ; Mon, 24 Aug 2020 21:59:51 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 294718248047 for ; Tue, 25 Aug 2020 01:59:51 +0000 (UTC) X-FDA: 77187434982.05.nerve58_580746827058 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 018A61801E69C for ; Tue, 25 Aug 2020 01:59:50 +0000 (UTC) X-Spam-Summary: 1,0,0,e91ff19d7688e845,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1534:1542:1585:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2915:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3872:4250:4321:4385:5007:6261:6653:7514:7903:10004:10400:10450:10455:11026:11658:11914:12043:12048:12291:12296:12297:12438:12521:12555:12679:12895:13161:13229:14181:14394:14721:19904:19999:21080:21451:21627:21740:21990:30054,0,RBL:210.61.82.184:@mediatek.com:.lbl8.mailshell.net-62.2.12.100 64.100.201.201;04yfeu4pigbbpniap8wxooid911tgycyh6fdfyaqs4gocx1ojnek8z461f9niti.3ko4g68ppoxuhk8owh3idipkzc87g7y3nsqh4ruwosse4f1qim5ri9tf16inm39.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: nerve58_580746827058 X-Filterd-Recvd-Size: 4927 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 01:59:49 +0000 (UTC) X-UUID: 98a7e483496941cebb1de58f45bc043b-20200825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=epF31PMWeocflqrG14ZTfXrn/tbNID2roIzjg+E6Ras=; b=AEwEMb9K8jHXQhtm1jmHcpHTtD9AbzKGC1usSQ3WtypOZF91E8I/dhllIU1p5SfTEpIkY/X6Ampw+WyFNU6/Q4iuQvaQJnYbFDxI+pGJ+gozbRiOVp8MQQbmKgXlinFRi2Pnd/72tdJMvCgnKX6pmiDiWHob/9a66pE/o+K3ISk=; X-UUID: 98a7e483496941cebb1de58f45bc043b-20200825 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 389396664; Tue, 25 Aug 2020 09:59:45 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Aug 2020 09:59:43 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Aug 2020 09:59:44 +0800 From: Walter Wu To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger CC: , , , , wsd_upstream , , Walter Wu , Andrey Konovalov Subject: [PATCH v3 4/6] kasan: add tests for timer stack recording Date: Tue, 25 Aug 2020 09:59:42 +0800 Message-ID: <20200825015942.28005-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Rspamd-Queue-Id: 018A61801E69C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Adds a test to verify timer stack recording and print it in KASAN report. The KASAN report was as follows(cleaned up slightly): BUG: KASAN: use-after-free in kasan_timer_uaf Freed by task 0: kasan_save_stack+0x24/0x50 kasan_set_track+0x24/0x38 kasan_set_free_info+0x20/0x40 __kasan_slab_free+0x10c/0x170 kasan_slab_free+0x10/0x18 kfree+0x98/0x270 kasan_timer_function+0x1c/0x28 Last potentially related work creation: kasan_save_stack+0x24/0x50 kasan_record_tmr_stack+0xa8/0xb8 init_timer_key+0xf0/0x248 kasan_timer_uaf+0x5c/0xd8 Signed-off-by: Walter Wu Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Matthias Brugger Cc: Andrey Konovalov --- lib/test_kasan.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 6e5fb05d42d8..2bd61674c7a3 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -821,6 +821,30 @@ static noinline void __init kasan_rcu_uaf(void) call_rcu(&global_ptr->rcu, kasan_rcu_reclaim); } +static noinline void __init kasan_timer_function(struct timer_list *timer) +{ + del_timer(timer); + kfree(timer); +} + +static noinline void __init kasan_timer_uaf(void) +{ + struct timer_list *timer; + + timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL); + if (!timer) { + pr_err("Allocation failed\n"); + return; + } + + timer_setup(timer, kasan_timer_function, 0); + add_timer(timer); + msleep(100); + + pr_info("use-after-free on timer\n"); + ((volatile struct timer_list *)timer)->expires; +} + static int __init kmalloc_tests_init(void) { /* @@ -869,6 +893,7 @@ static int __init kmalloc_tests_init(void) kmalloc_double_kzfree(); vmalloc_oob(); kasan_rcu_uaf(); + kasan_timer_uaf(); kasan_restore_multi_shot(multishot); From patchwork Tue Aug 25 02:00:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11734691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CA70138A for ; Tue, 25 Aug 2020 02:00:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD561204FD for ; Tue, 25 Aug 2020 02:00:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="snlOgSvp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD561204FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2ABF06B00C4; Mon, 24 Aug 2020 22:00:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 25CBA8D0002; Mon, 24 Aug 2020 22:00:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 199C16B00C6; Mon, 24 Aug 2020 22:00:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id 0572C6B00C4 for ; Mon, 24 Aug 2020 22:00:18 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BC3048248047 for ; Tue, 25 Aug 2020 02:00:17 +0000 (UTC) X-FDA: 77187436074.26.guide20_5d060e427058 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 83F1E1804B669 for ; Tue, 25 Aug 2020 02:00:17 +0000 (UTC) X-Spam-Summary: 1,0,0,36f6b4f44dd420cd,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1535:1542:1585:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2915:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3872:4250:4385:5007:6261:6653:7514:7903:9707:10004:10400:11026:11658:11914:12043:12048:12291:12296:12297:12438:12521:12555:12679:12895:13161:13229:14181:14394:14721:21080:21451:21627:21740:21990:30054,0,RBL:210.61.82.183:@mediatek.com:.lbl8.mailshell.net-62.2.12.100 64.100.201.201;04y8dsoxkpajkha9ja6xtpsrcks95op86k1nnyp5nabz9p1ijeecy4sfhqj8k5f.ttcmmz6cby164afzzsxz4w3sohe68qybq6frnknm7g6wfj3yxop4zohj3kt8ztx.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: guide20_5d060e427058 X-Filterd-Recvd-Size: 5339 Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 02:00:16 +0000 (UTC) X-UUID: da200875e771434fb8ea2e4074119a4e-20200825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=+uEb+COBoPnYhqxN0aa+Ix9E1vWCkdkDaOsAXwUlrdg=; b=snlOgSvp6Ydfa9GQsyZ0okgQarXlwCKKK0WFjIUGHC/csH+0BLUWNMK+Fkztw2CgANdzNJmSsWwe0pWEizJ4+AYsTZGfFL3eUCS59qQPWjQLi63O5jinLFRMDX99A9hvK8jKhR3lm9seKXi1sQBQLTeWGUm6JohUr33nVOPq/ac=; X-UUID: da200875e771434fb8ea2e4074119a4e-20200825 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 555672964; Tue, 25 Aug 2020 10:00:12 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Aug 2020 10:00:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Aug 2020 10:00:11 +0800 From: Walter Wu To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger CC: , , , , wsd_upstream , , Walter Wu , Andrey Konovalov Subject: [PATCH v3 5/6] kasan: add tests for workqueue stack recording Date: Tue, 25 Aug 2020 10:00:08 +0800 Message-ID: <20200825020008.28682-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: 6777E2A49D633339955E856E650F8D381A2BE95487C4F41DF024165C8168C8D82000:8 X-MTK: N X-Rspamd-Queue-Id: 83F1E1804B669 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: Adds a test to verify workqueue stack recording and print it in KASAN report. The KASAN report was as follows(cleaned up slightly): BUG: KASAN: use-after-free in kasan_workqueue_uaf Freed by task 54: kasan_save_stack+0x24/0x50 kasan_set_track+0x24/0x38 kasan_set_free_info+0x20/0x40 __kasan_slab_free+0x10c/0x170 kasan_slab_free+0x10/0x18 kfree+0x98/0x270 kasan_workqueue_work+0xc/0x18 Last potentially related work creation: kasan_save_stack+0x24/0x50 kasan_record_wq_stack+0xa8/0xb8 insert_work+0x48/0x288 __queue_work+0x3e8/0xc40 queue_work_on+0xf4/0x118 kasan_workqueue_uaf+0xfc/0x190 Signed-off-by: Walter Wu Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Matthias Brugger Cc: Andrey Konovalov --- lib/test_kasan.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 2bd61674c7a3..7293a55ff51c 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -845,6 +845,34 @@ static noinline void __init kasan_timer_uaf(void) ((volatile struct timer_list *)timer)->expires; } +static noinline void __init kasan_workqueue_work(struct work_struct *work) +{ + kfree(work); +} + +static noinline void __init kasan_workqueue_uaf(void) +{ + struct workqueue_struct *workqueue; + struct work_struct *work; + + workqueue = create_workqueue("kasan_wq_test"); + if (!workqueue) { + pr_err("Allocation failed\n"); + return; + } + work = kmalloc(sizeof(struct work_struct), GFP_KERNEL); + if (!work) { + pr_err("Allocation failed\n"); + return; + } + + INIT_WORK(work, kasan_workqueue_work); + queue_work(workqueue, work); + destroy_workqueue(workqueue); + + pr_info("use-after-free on workqueue\n"); + ((volatile struct work_struct *)work)->data; +} static int __init kmalloc_tests_init(void) { /* @@ -894,6 +922,7 @@ static int __init kmalloc_tests_init(void) vmalloc_oob(); kasan_rcu_uaf(); kasan_timer_uaf(); + kasan_workqueue_uaf(); kasan_restore_multi_shot(multishot); From patchwork Tue Aug 25 02:02:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Wu X-Patchwork-Id: 11734695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14843138A for ; Tue, 25 Aug 2020 02:02:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CBCD1204EC for ; Tue, 25 Aug 2020 02:02:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="eS/4hTLS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBCD1204EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0FCBA90001F; Mon, 24 Aug 2020 22:02:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0AD258D0002; Mon, 24 Aug 2020 22:02:19 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F06EF90001F; Mon, 24 Aug 2020 22:02:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id DE2298D0002 for ; Mon, 24 Aug 2020 22:02:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A0A1A8248047 for ; Tue, 25 Aug 2020 02:02:18 +0000 (UTC) X-FDA: 77187441156.13.uncle09_3114b0927058 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 73E4B18140B60 for ; Tue, 25 Aug 2020 02:02:18 +0000 (UTC) X-Spam-Summary: 1,0,0,843f917107838964,d41d8cd98f00b204,walter-zh.wu@mediatek.com,,RULES_HIT:41:355:379:421:541:800:960:973:988:989:1042:1185:1260:1277:1311:1313:1314:1345:1431:1437:1514:1515:1516:1518:1534:1541:1585:1711:1730:1747:1777:1792:1978:1981:2194:2198:2199:2200:2393:2559:2562:2895:2901:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3872:3874:4250:4321:5007:6119:6261:6653:7875:8660:10004:10400:11232:11658:11914:12043:12048:12198:12297:12521:12555:12895:12986:13069:13148:13200:13229:13230:13311:13357:14181:14394:14721:21080:21451:21627:21740:21772:21939:30012:30054:30070,0,RBL:210.61.82.184:@mediatek.com:.lbl8.mailshell.net-64.100.201.201 62.2.12.100;04yg8q3gfn5mmqmp33qhrozge73bpopg46ezu3hfwq3ezyh9zastec417kc3cag.3go33s59b8f9cbcw7kf14k9mtggrotmignqfznjjssaqupqzjt5db1zkuko9h81.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:101,LUA_SUMMARY:none X-HE-Tag: uncle09_3114b0927058 X-Filterd-Recvd-Size: 4128 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 02:02:17 +0000 (UTC) X-UUID: df1774462e404d7ebe32eb71e825ac0c-20200825 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=9sZ1Q2VJIj3D6DYv93PbNUEMzsMoXEFwRyYq2J0814A=; b=eS/4hTLSwSIlOSRdtmlkPcp10xhkBJIWzxLyocPknHUVExR6agIKJhUSC6Bf7It1N/LRzRlTLvF2n46A2IAAEJx8h6GtIYLV5ynqXKNVA0qq6LD6eXbmHZNW5lmjT37kOAFfSBvAAz4gE3iQG/ilInAUNH3AOFnnP88FyBrzfEI=; X-UUID: df1774462e404d7ebe32eb71e825ac0c-20200825 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1653110723; Tue, 25 Aug 2020 10:02:10 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 25 Aug 2020 10:02:08 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Aug 2020 10:02:09 +0800 From: Walter Wu To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Matthias Brugger , Jonathan Corbet CC: , , , , wsd_upstream , , Walter Wu Subject: [PATCH v3 6/6] kasan: update documentation for generic kasan Date: Tue, 25 Aug 2020 10:02:08 +0800 Message-ID: <20200825020208.28950-1-walter-zh.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: FF79C89B95B5EEC808E61E9DE96777FD0981D12178444CA2009311433735FC3A2000:8 X-MTK: N X-Rspamd-Queue-Id: 73E4B18140B60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.012366, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Generic KASAN also supports to record the last two timer and workqueue stacks and print them in KASAN report. So that need to update documentation. Signed-off-by: Walter Wu Suggested-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Jonathan Corbet --- v3: - Thanks for Macro suggestion --- Documentation/dev-tools/kasan.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index 38fd5681fade..698ccb65e634 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -190,8 +190,9 @@ function calls GCC directly inserts the code to check the shadow memory. This option significantly enlarges kernel but it gives x1.1-x2 performance boost over outline instrumented kernel. -Generic KASAN prints up to 2 call_rcu() call stacks in reports, the last one -and the second to last. +Generic KASAN also reports the last 2 call stacks to creation of work that +potentially has access to an object. Call stacks for the following are shown: +call_rcu(), timer and workqueue queuing. Software tag-based KASAN ~~~~~~~~~~~~~~~~~~~~~~~~