Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1177607pxb; Tue, 19 Oct 2021 23:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbKNwBAebcRrIENvgg7Wi8OW/eX5SVYCzp/nfzUdgArTok6YhcDCpLoJti290PdwKlE8MG X-Received: by 2002:a05:6402:5c2:: with SMTP id n2mr59794316edx.239.1634710645269; Tue, 19 Oct 2021 23:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634710645; cv=none; d=google.com; s=arc-20160816; b=wl1nLEhxbly+/p8bqmLBlQWd33cCVKTDuXlFHiy6+IziZB+GIbwzXBkWXgFlonqmnM CMeux/431gzBqExL1H12v50oVMpCLnoiSmPCIjiL0hfxmUXR9J/VRnjNV7V587VDJzgp XWI0EWEvWssiEmBgU1RyNr7lcY8LoZU/MAUfy+fozdYvY19/EQwJ81YVKf0CwdQPTK7g QW4vMc429Ua+CNumUYlheP1abn17TkFCFfcklPePtrrSYjroYnJaQkADerLw8LOSRMn2 wfwE5UxSFInxmrZseW6RlfbYZjbj/Igu3rrzh1CC2CgmeZH9NMrsAFiHF3MthYwMu728 ZivQ== 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=dq94LENGeOH5kscGjO4AeiggaLkHNIev5GtO7EAkipM=; b=iLgRW0hR1OHzAxWIwBrFc+bohoJKSShGlQ0IAs8Nf5ZC28EXb42/FvXLsHS0fim2D0 uzzjJN1peLBGV3BqzgJttxb6opACu7IdUrxzldqjyMLTOllXd3vDyhoTJlV3BJBN4t3W I28r1lzxL28O6x1M15E7uWM7GFQ7tRXaYnn7IA8Z6kniacjIDzRpckXoC2RN4pQ+rqBO tfT2I4kcSxF0vQU7dZqk/r+RMOAg12bXpfl5/RsO7RDhlkcLET6tdIEH0sXyrRMXuwIU 81kMIqvdNDPHoawExKz4/+sTnj8GFA0+iXTlI7874x8O6XGKpokttzGb8dS5IPo5IO+W lm8Q== 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 hq3si3048146ejc.142.2021.10.19.23.17.01; Tue, 19 Oct 2021 23:17:25 -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 S229820AbhJTGPN (ORCPT + 99 others); Wed, 20 Oct 2021 02:15:13 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:56854 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229591AbhJTGPN (ORCPT ); Wed, 20 Oct 2021 02:15:13 -0400 X-UUID: 154ad8d91b31496bb95a5cc342c30621-20211020 X-UUID: 154ad8d91b31496bb95a5cc342c30621-20211020 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 493942100; Wed, 20 Oct 2021 14:12:55 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Wed, 20 Oct 2021 14:12:54 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 20 Oct 2021 14:12:54 +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 v2] kasan: add kasan mode messages when kasan init Date: Wed, 20 Oct 2021 14:12:48 +0800 Message-ID: <20211020061248.13270-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 --- change since v2: - Rebase to linux-next - HW-tags based mode need to consider asymm mode - Thanks for Marco's suggestion arch/arm64/mm/kasan_init.c | 2 +- mm/kasan/hw_tags.c | 4 +++- mm/kasan/kasan.h | 10 ++++++++++ mm/kasan/sw_tags.c | 2 +- 4 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..1d5c89c7cdfe 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -177,7 +177,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/kasan.h b/mm/kasan/kasan.h index aebd8df86a1f..387ed7b6de37 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -36,6 +36,16 @@ static inline bool kasan_sync_fault_possible(void) { return kasan_mode == KASAN_MODE_SYNC || kasan_mode == KASAN_MODE_ASYMM; } + +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"; +} #else static inline bool kasan_stack_collection_enabled(void) 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