Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1326334pxb; Wed, 20 Oct 2021 02:51:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ0EzkP6L5O3hCnYg349XCr2/JmI2xSdOhquqIWTX1Jxrkd6QlWFq6HK7ylOcjhg+H9BB4 X-Received: by 2002:a50:9fcc:: with SMTP id c70mr57925280edf.179.1634723496122; Wed, 20 Oct 2021 02:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634723496; cv=none; d=google.com; s=arc-20160816; b=sickF/0vK06OQCw2ItOIrWF1/k5nfYruL+WXamOiJHuqShz+OCyniMb6DwKplSxXim pMBQhPGlc9UebqhtKrXBe+0Y00MZfhRVz0yku+id5/zDGlQ8Ty4H9q40elTrn2HMdtqV x5WebW9RH9AEqrEHTrYQ4xPKP8Qf4wruWodJAMmZXPrFwHlyq3JDxDNbXsbiNp1DtUiQ rtLt36H4H73IZ/NKz/DNH59YnYMP5miUM3hD8WrX7Sf4XX9t1V7BdalbrXVmnOATZgfu NiKF8c/coMTu9N801LMUJdZZ04DlLPSeKnyJl6Owh0jQB+e37uy2NhEOW4FisCjrTO/U 2zxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=jTLv3LKQrUqvNnJ57kOgsX9tqUVTnd7eZay6F0YEiF0=; b=LqVl/C64Nw0jTBKMtt5MPF9j68truYulvsY6Y4+ZwZ3dE1pcyMejHA6spdYecer37P B6YLkE618vx7NpDpjvsBF/MVTzDoIPpYl0KS71vUdC09psgzF6SNcAd0AoH7y8f9/wLj LWYG9i3ZjuiptKrNFrzWbI1kUS3gELrlK8XGyfXZqooxZwZ+AHjRLQauS0ovjA73fRPT 35kJ8bqkrOTI/kXXXbrKk5ZNQRQtpDW/dhyucqdJ9rnxSONQAjQxoUtw+cUyoftbhqGe zAuSuX+xVCp2d5Tv7Yr829mJ69FZTyy3GhC/L7L7gqoM8LpKP56QMxIa4nPWV9Mx6Rlq kJzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y4si2918763edc.473.2021.10.20.02.51.11; Wed, 20 Oct 2021 02:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbhJTJvR (ORCPT + 99 others); Wed, 20 Oct 2021 05:51:17 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:49606 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230031AbhJTJvQ (ORCPT ); Wed, 20 Oct 2021 05:51:16 -0400 X-UUID: 52b919d9a5ba49d6a32525d28890f2c0-20211020 X-UUID: 52b919d9a5ba49d6a32525d28890f2c0-20211020 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1720517181; Wed, 20 Oct 2021 17:48:54 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Wed, 20 Oct 2021 17:48:52 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 20 Oct 2021 17:48:52 +0800 From: Kuan-Ying Lee To: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Catalin Marinas , Will Deacon , Andrew Morton , "Matthias Brugger" , Marco Elver CC: , , , , , , , , Kuan-Ying Lee Subject: [PATCH v3] kasan: add kasan mode messages when kasan init Date: Wed, 20 Oct 2021 17:48:50 +0800 Message-ID: <20211020094850.4113-1-Kuan-Ying.Lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are multiple kasan modes. It makes sense that we add some messages to know which kasan mode is when booting up. see [1]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=212195 [1] Signed-off-by: Kuan-Ying Lee --- v3: - Rebase to linux-next - Move kasan_mode_info() into hw_tags.c v2: - Rebase to linux-next - HW-tag based mode need to consider asymm mode - Thanks Marco's suggestion arch/arm64/mm/kasan_init.c | 2 +- mm/kasan/hw_tags.c | 14 +++++++++++++- mm/kasan/sw_tags.c | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 5b996ca4d996..6f5a6fe8edd7 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -309,7 +309,7 @@ void __init kasan_init(void) kasan_init_depth(); #if defined(CONFIG_KASAN_GENERIC) /* CONFIG_KASAN_SW_TAGS also requires kasan_init_sw_tags(). */ - pr_info("KernelAddressSanitizer initialized\n"); + pr_info("KernelAddressSanitizer initialized (generic)\n"); #endif } diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c index dc892119e88f..7355cb534e4f 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -106,6 +106,16 @@ static int __init early_kasan_flag_stacktrace(char *arg) } early_param("kasan.stacktrace", early_kasan_flag_stacktrace); +static inline const char *kasan_mode_info(void) +{ + if (kasan_mode == KASAN_MODE_ASYNC) + return "async"; + else if (kasan_mode == KASAN_MODE_ASYMM) + return "asymm"; + else + return "sync"; +} + /* kasan_init_hw_tags_cpu() is called for each CPU. */ void kasan_init_hw_tags_cpu(void) { @@ -177,7 +187,9 @@ void __init kasan_init_hw_tags(void) break; } - pr_info("KernelAddressSanitizer initialized\n"); + pr_info("KernelAddressSanitizer initialized (hw-tags, mode=%s, stacktrace=%s)\n", + kasan_mode_info(), + kasan_stack_collection_enabled() ? "on" : "off"); } void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags) diff --git a/mm/kasan/sw_tags.c b/mm/kasan/sw_tags.c index bd3f540feb47..77f13f391b57 100644 --- a/mm/kasan/sw_tags.c +++ b/mm/kasan/sw_tags.c @@ -42,7 +42,7 @@ void __init kasan_init_sw_tags(void) for_each_possible_cpu(cpu) per_cpu(prng_state, cpu) = (u32)get_cycles(); - pr_info("KernelAddressSanitizer initialized\n"); + pr_info("KernelAddressSanitizer initialized (sw-tags)\n"); } /* -- 2.18.0