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: 12333353 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 10A86C49EA2 for ; Sun, 20 Jun 2021 11:50:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE7066113C for ; Sun, 20 Jun 2021 11:50:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE7066113C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OHNpkey2vr8xWSDcUCO/Eac70VOlQeMpiGu/ICqUkkc=; b=Oy9Lv3oXxBcl/s 4enoaLbhXuEuLcvz+3kF6viiHDB3nMI3xMXB61w5i/ozGCxaWRapU7emIW63zQtM4E4iDhCzvVqcd 3gkQXx7imXuf3GpORNca2GtTS+Y6ihTn0bej6UZgQ+BDY1IT3K2TUab65URbmvu4nfaBCqPzvAhG7 33gliSAu8/Nrz8q8/TOCy2foLV5b1wTBRBCwkNk++Mi+XZyV4kmSsnnEmvNal/49oVKx3+V0M7RrN y7LJQIRrWGVztJQC4jUJ32FnQVkkcuSXyb2KV2ZBApJtzZrTiP3DEFgDzAOTo0rkX42wH00MXjVvD BtFvEyAVjaWHk02J1zUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1luvwA-000us0-JJ; Sun, 20 Jun 2021 11:48:26 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1luvw1-000upl-WD; Sun, 20 Jun 2021 11:48:19 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210620_044818_068535_F18D2F55 X-CRM114-Status: GOOD ( 12.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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