From patchwork Sat Jun 12 04:51:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Ying Lee X-Patchwork-Id: 12316867 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 E5271C48BE5 for ; Sat, 12 Jun 2021 04:52:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B6886109E for ; Sat, 12 Jun 2021 04:52:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B6886109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 204446B0071; Sat, 12 Jun 2021 00:52:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B4106B0072; Sat, 12 Jun 2021 00:52:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07C416B0073; Sat, 12 Jun 2021 00:52:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CC2766B0071 for ; Sat, 12 Jun 2021 00:52:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5AC2F1DE6 for ; Sat, 12 Jun 2021 04:52:53 +0000 (UTC) X-FDA: 78243851826.07.F48624C Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf18.hostedemail.com (Postfix) with ESMTP id 522032001060 for ; Sat, 12 Jun 2021 04:52:47 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so1817313pjn.1 for ; Fri, 11 Jun 2021 21:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MnfTyPm3bgkOaqftF6Jo/n40i23c68ZJNhoFhLCQROQ=; b=n0uBf4U1sqSecxH8rPEucH91yjL9lJa88BRoLf6hAbY8X4la/Itg3RO164HwvkjygA vIrZpaz5Ip1ar0Vmn88wlSIMnKpzPh1YLNZkF/yANot3VSeEVSJkvFzhanvoa4/ZDIn5 Yg8n/k3lwQ93+oUMnmt4F/0M3ghv0nbXlHOrduQC15XXjZBeu4x/vtY/TjrVbFvXFQU3 pgUJvwJ1e4aAD0a/xJZWy6OQEYwsi/8RKjLaXFDe0138CylfXrRBxmzu+XjYgURMwYj4 AH6qHOkJM0CQiJaLCfrSrDcpc2ZogZ44k3W76Y8BYeUnlf12DvNsqGWAPTlJpozB6lf2 qPoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MnfTyPm3bgkOaqftF6Jo/n40i23c68ZJNhoFhLCQROQ=; b=s5zCEknlU6lAhvTKHQJffTTq27iw3j9kaTYlEPQgYnvK3W3sPiUe6iHw9VJVSl6S6W vhAXUbebByx/yRLL5nlnZkMEQOYs6TNxzRB7icRBrbUQVZibM6GNXjmmztNJN/8sAacW 0yR5u/KPP9gbbjxcRf2djC/GgralmQNscIj6l1QWTseN59+E/yHjZmz28v6ye2RDjkfd eHCF7bW9hePGw8vqTGH6oJzh2JID1xrZ0c26Lo9b10EiHgf7Gfr+odaisZJ4rfsgBdU1 Bp0M2wTNofncne1F/O3Kc9bmgeMBUYi3xZ7gb5L1I+AWv/PDm53WCfDqz0G77O+9tm+7 GtnA== X-Gm-Message-State: AOAM530X6mPN/itb85bYdyoO5UFhmEAVt5vJz396z8jG9o7RWWzqMLda u1OK7AosYPxFLeTu+fyVzm8= X-Google-Smtp-Source: ABdhPJy2DLxABi4UfSPVDjOIsMkF7VS6GItUSiF7mtxu4wZNMGNTJ3tdwn4DJtYFVBFgwAmZN4gIUQ== X-Received: by 2002:a17:902:d305:b029:10d:c8a3:657f with SMTP id b5-20020a170902d305b029010dc8a3657fmr7008127plc.0.1623473572326; Fri, 11 Jun 2021 21:52:52 -0700 (PDT) Received: from lee-virtual-machine.localdomain (61-230-42-225.dynamic-ip.hinet.net. [61.230.42.225]) by smtp.gmail.com with ESMTPSA id m1sm6076572pgd.78.2021.06.11.21.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 21:52:51 -0700 (PDT) From: Kuan-Ying Lee To: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Andrew Morton Cc: kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Kuan-Ying Lee , Marco Elver Subject: [PATCH v2 3/3] kasan: add memory corruption identification support for hardware tag-based mode Date: Sat, 12 Jun 2021 12:51:56 +0800 Message-Id: <20210612045156.44763-4-kylee0686026@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210612045156.44763-1-kylee0686026@gmail.com> References: <20210612045156.44763-1-kylee0686026@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 522032001060 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=n0uBf4U1; spf=pass (imf18.hostedemail.com: domain of kylee0686026@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=kylee0686026@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: dtzo9nafxso7ywhrse49ywndofemu4n9 X-HE-Tag: 1623473567-197662 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 --- 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