Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1244664pxb; Wed, 20 Oct 2021 00:51:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIohTu7OnJorP2dUcMCqpC5fyA3NatYrvkcC/C35l6nlkA4ZNTO6zhkMzlOInsozu5qKY5 X-Received: by 2002:a50:e188:: with SMTP id k8mr62934278edl.119.1634716290924; Wed, 20 Oct 2021 00:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634716290; cv=none; d=google.com; s=arc-20160816; b=CUMTaWALNB6cUSKplAfa7/C5QhuYDJyylt5CHYOQMvsRkfMlJ8S2PlMBMMwB/ilkWF AXMjhIHLdpVFR7o6m3pwCZv2oc2U2i+2/1oolzOB6qi2C1ABcWVKbJGdCNAyVVnqR9HT 3rjZeyXRJuRU6gas8OB7CraC6muOke6/2iRkv9hpwp6p8KFCohIce1tsmNMTfY7Ag2zf EZ9ohpwNtbg2uwDUYJqI3HDJcVqvmydbiTs7eXLUoRsMEGF6fhsul46dHbFwitKlJ4fw 747J2lYKMp3NHyOuwpXj050iiIs8DQ/mZ+bopiYCXgp0LuDL6nzWck2J4bm0oKnHdNLM F3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=26QuId4hJCn4piktDCW1s4WEHrK9FVM2POMNNriOPPs=; b=wqD/fn2wy47+8ndKXqRr3oiXR2j6/ST6bfBuiaQ14mieecWZ+eyPZEOdV7vL58lrYp uC/RcZ7nV6J8DsbLis2ToKjY1DGqgE7+AkK/t1YRSSx0c8ZE4rW1/8zo4Y3XUOWB5CTP c2Efv/f2/AOzoOMW7E7zc4F+rIlIk9sU042FnXXx1R3UtWzOwu7Fqwpp4lOfOH8q5nE5 mMRfb1EjWXGHx17ZDjBJcnB5H7wurPq/DvTAEf2iReI0z66AbhjPs+rz8tSrjRfEN1IB XC3jZRxBbWKpbHINJPQNQ7HL2NWROvn2oiDhO29DZpslSYvyosJfls9z/AvSZwO8EFmA MXNg== 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 m1si2539862ejr.261.2021.10.20.00.51.07; Wed, 20 Oct 2021 00:51:30 -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 S229639AbhJTHtC (ORCPT + 99 others); Wed, 20 Oct 2021 03:49:02 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:54338 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229544AbhJTHtC (ORCPT ); Wed, 20 Oct 2021 03:49:02 -0400 X-UUID: 391e0a9f321e4572aaeb44daab13c9a6-20211020 X-UUID: 391e0a9f321e4572aaeb44daab13c9a6-20211020 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2121538419; Wed, 20 Oct 2021 15:46:46 +0800 Received: from mtkexhb02.mediatek.inc (172.21.101.103) 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 15:46:41 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkexhb02.mediatek.inc (172.21.101.103) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 20 Oct 2021 15:46:40 +0800 Received: from mtksdccf07 (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 15:46:40 +0800 Message-ID: Subject: Re: [PATCH v2] kasan: add kasan mode messages when kasan init From: Kuan-Ying Lee To: Marco Elver CC: Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Catalin Marinas , "Will Deacon" , Andrew Morton , Matthias Brugger , Chinwen Chang =?UTF-8?Q?=28=E5=BC=B5=E9=8C=A6=E6=96=87=29?= , Yee Lee =?UTF-8?Q?=28=E6=9D=8E=E5=BB=BA=E8=AA=BC=29?= , Nicholas Tang =?UTF-8?Q?=28=E9=84=AD=E7=A7=A6=E8=BC=9D=29?= , "kasan-dev@googlegroups.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-mediatek@lists.infradead.org" Date: Wed, 20 Oct 2021 15:46:40 +0800 In-Reply-To: References: <20211020061248.13270-1-Kuan-Ying.Lee@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2021-10-20 at 15:23 +0800, Marco Elver wrote: > On Wed, 20 Oct 2021 at 08:13, Kuan-Ying Lee < > Kuan-Ying.Lee@mediatek.com> wrote: > > > > 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://urldefense.com/v3/__https://bugzilla.kernel.org/show_bug.cgi?id=212195__;!!CTRNKA9wMg0ARbw!yylpqk8mnd0N8w6pn4Mn4sIeu-GGlKXcA4I4yXlmstFsuqmpkhaM2V_uu2c6oPMFpZRqoQ$ > > $ [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"; > > +} > > This creates an inconsistency, because for > kasan_stack_collection_enabled(), kasan_async_fault_possible(), and > kasan_sync_fault_possible() there are !KASAN_HW_TAGS stubs. > > A stub for kasan_mode_info() if !KASAN_HW_TAGS appears useless > though, > and I wouldn't know what its return value should be. > > Do you expect this helper to be used outside hw_tags.c? If not, > perhaps just move it into hw_tags.c. The helper will be used only in hw_tags.c. I will move it into hw_tags.c in v3. Thanks. > > Thanks, > -- Marco