From patchwork Sun Jun 20 11:47:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= X-Patchwork-Id: 12333369 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=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT 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 80CD7C48BDF for ; Sun, 20 Jun 2021 11:48:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2F3836113C for ; Sun, 20 Jun 2021 11:48:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F3836113C 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 C6DA56B0070; Sun, 20 Jun 2021 07:48:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF6046B0072; Sun, 20 Jun 2021 07:48:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A48E18D0001; Sun, 20 Jun 2021 07:48:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 6A8726B0070 for ; Sun, 20 Jun 2021 07:48:19 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0A14ABA18 for ; Sun, 20 Jun 2021 11:48:19 +0000 (UTC) X-FDA: 78273929118.18.2D78BB1 Received: from mailgw02.mediatek.com (mailgw02.mediatek.com [216.200.240.185]) by imf12.hostedemail.com (Postfix) with ESMTP id CCA831408 for ; Sun, 20 Jun 2021 11:48:14 +0000 (UTC) X-UUID: ba56145a117f445ba4914df3cd0d6f60-20210620 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:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=1ehNfxhQF003Q1AspMXF1u4SvZvRqCEpn9DzXdgrYDY=; b=JHii1c2Ln7LHjMWpWuQW6YpK00VMOZnX2fes3Pq3OUxMp83wJLPkLF6K8kd9t2jVPf18qjfouL+nQGbKHcOXFCwbBlDC+Hq9E/z/IiNfCkGTA5iEma2vaOKahnCwkVlirPPfGQxwXQOgge+Cm4KG2KDm5Z38Jvg3lftKreCvt8s=; X-UUID: ba56145a117f445ba4914df3cd0d6f60-20210620 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 240175482; Sun, 20 Jun 2021 04:48:14 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Jun 2021 04:48:13 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Jun 2021 19:48: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; Sun, 20 Jun 2021 19:48:11 +0800 From: Kuan-Ying Lee To: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Marco Elver , Dmitry Vyukov , Andrew Morton , Matthias Brugger CC: , , , , , , , , Kuan-Ying Lee Subject: [PATCH v3 3/3] kasan: add memory corruption identification support for hardware tag-based mode Date: Sun, 20 Jun 2021 19:47:56 +0800 Message-ID: <20210620114756.31304-4-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210620114756.31304-1-Kuan-Ying.Lee@mediatek.com> References: <20210620114756.31304-1-Kuan-Ying.Lee@mediatek.com> MIME-Version: 1.0 X-MTK: N Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=JHii1c2L; dmarc=pass (policy=none) header.from=mediatek.com; spf=pass (imf12.hostedemail.com: domain of kuan-ying.lee@mediatek.com designates 216.200.240.185 as permitted sender) smtp.mailfrom=kuan-ying.lee@mediatek.com X-Rspamd-Server: rspam02 X-Stat-Signature: htqsb3jxdr4uj36wy6mqod414xtd4r7i X-Rspamd-Queue-Id: CCA831408 X-HE-Tag: 1624189694-770179 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: Add memory corruption identification support for hardware tag-based mode. We store one old free pointer tag and free backtrace. Signed-off-by: Kuan-Ying Lee Suggested-by: Marco Elver Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Andrew Morton Reviewed-by: Alexander Potapenko Reviewed-by: Andrey Konovalov --- lib/Kconfig.kasan | 2 +- mm/kasan/kasan.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 6f5d48832139..2cc25792bc2f 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -157,7 +157,7 @@ config KASAN_STACK config KASAN_TAGS_IDENTIFY bool "Enable memory corruption identification" - depends on KASAN_SW_TAGS + depends on KASAN_SW_TAGS || KASAN_HW_TAGS help This option enables best-effort identification of bug type (use-after-free or out-of-bounds) at the cost of increased diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index b0fc9a1eb7e3..d6f982b8a84e 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -153,7 +153,7 @@ struct kasan_track { depot_stack_handle_t stack; }; -#ifdef CONFIG_KASAN_TAGS_IDENTIFY +#if defined(CONFIG_KASAN_TAGS_IDENTIFY) && defined(CONFIG_KASAN_SW_TAGS) #define KASAN_NR_FREE_STACKS 5 #else #define KASAN_NR_FREE_STACKS 1