From patchwork Tue Nov 10 22:10:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11895539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACE40138B for ; Tue, 10 Nov 2020 22:11:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6ABCC20637 for ; Tue, 10 Nov 2020 22:11:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="IQSSQ/5E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ABCC20637 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7F1BF6B009D; Tue, 10 Nov 2020 17:11:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7C5396B009E; Tue, 10 Nov 2020 17:11:49 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DE676B009F; Tue, 10 Nov 2020 17:11:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 40C636B009D for ; Tue, 10 Nov 2020 17:11:49 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DD2118249980 for ; Tue, 10 Nov 2020 22:11:48 +0000 (UTC) X-FDA: 77469906696.20.brake36_1e1518e272f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id B2A19180C07AB for ; Tue, 10 Nov 2020 22:11:48 +0000 (UTC) X-Spam-Summary: 50,3,0,2064eb8f9744cae6,d41d8cd98f00b204,3ixcrxwokcpiuhxlysehpfaiiafy.wigfchor-ggepuwe.ila@flex--andreyknvl.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1042:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:1981:2178:2194:2199:2393:2559:2562:2904:3138:3139:3140:3141:3142:3152:3354:3865:3866:3871:3872:4117:4250:4321:4605:5007:6119:6261:6653:6742:7514:8957:9592:9969:10004:10400:11026:11232:11473:11657:11658:11914:12043:12296:12297:12438:12555:12895:13095:14181:14394:14659:14721:21080:21212:21365:21433:21444:21451:21627:21660:21772:30012:30029:30054,0,RBL:209.85.221.74:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yr3nuupidt1nfssnibf3zao9tfcoph5bczcb4nghm6s9jor319mpc1ehi1fuu.wpwn76cxuqdtsoch8oop5xyzcjwxwdys747gg8k9ot8m85kkmhudbp8588zyiya.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp, MSBL:0,D X-HE-Tag: brake36_1e1518e272f8 X-Filterd-Recvd-Size: 6861 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 22:11:48 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id h8so6208471wrt.9 for ; Tue, 10 Nov 2020 14:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=IoTt6hT7gjXNpuAqI7B1fpPr1ifOz5U3TNuE4drki+I=; b=IQSSQ/5EvtXOsAvA0C4gkWpk8iXWU9aT3frgkKOn9n43N1HbrXin9vh+pzPIB1/ava bvVxJDr0s4FNZM+rtEtbMO1C14wCfbs7vpGUkRxBhDH8MgmyJhnyxPjseaiUbL4nQWlH /AFMTOuKXmAU6Nw1T6lombpIsqsS2b3spIy/Q3IIJruxk1+PrXzIlwAmwArSVjKfC6nY oQbQoOAe6MiOhBAZRa7iW/NS3vA/tv5MbyZxwEujKb7Q3dOnQhEUbYR1kvnb9vBQ7nmS ZbOV37+rKxzlfGgVlloORrL/4LtZm0TBIEC1J1HWdieWQv9Nwav+DZPMoA/rJJZ04iI5 zuvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IoTt6hT7gjXNpuAqI7B1fpPr1ifOz5U3TNuE4drki+I=; b=KqbMF09DuAQxRVX7f4oxDDe4KCjNizZN3Vcgs+y0zRp9Mlzx+kItXdNvStuv4f8M6h /JXrxI/SmVcYlF/qg/i7VmfOjs27kkSeF3Fltb/IIfHtjfpEO+K5hXmqSlXmRo5lLMqZ RIOBH/Aa/KUgmaIJiEMqqlp0V+hVuNQtCMUv2kO8Ch00UD0j7vvsAD3QF6o9O3OFs4fC j29ye3Vw72Si84DdJt7gL0wppyJl9iF8fvLjduDY3Ajysqs9fnHY8BauLfQsjFfaX50p jdMmgR1DiIql4b7ju+l2qrjwt6cAbXsnygmVKdODrpVu8QFCFadPfc8qrMvFblmIa8Ly /ldQ== X-Gm-Message-State: AOAM531mKYBi2uGBTeev/JDc249PhGN4czwR3tTwCweEsaYfi7idHUbu 7RR7D6btp1XPCiWhm+ToMY+3ZpEsZkT7tfnW X-Google-Smtp-Source: ABdhPJxlyTfY00I9Cm6jRHzeHsN65kONp0z7f8pA/CcTE+RdvC5javSmbyoyRnujM9tyakI7PvL3qJSZ8WPmwtc0 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:7219:: with SMTP id n25mr232465wmc.61.1605046307132; Tue, 10 Nov 2020 14:11:47 -0800 (PST) Date: Tue, 10 Nov 2020 23:10:14 +0100 In-Reply-To: Message-Id: <619cb0edad35d946c4796976c25bddb5b3eb0c56.1605046192.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v9 17/44] kasan, arm64: move initialization message From: Andrey Konovalov To: Catalin Marinas Cc: Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov 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: Software tag-based KASAN mode is fully initialized with kasan_init_tags(), while the generic mode only requires kasan_init(). Move the initialization message for tag-based mode into kasan_init_tags(). Also fix pr_fmt() usage for KASAN code: generic.c doesn't need it as it doesn't use any printing functions; tag-based mode should use "kasan:" instead of KBUILD_MODNAME (which stands for file name). Signed-off-by: Andrey Konovalov Reviewed-by: Catalin Marinas Reviewed-by: Alexander Potapenko --- Change-Id: Iddca9764b30ff0fab1922f26ca9d4f39b6f22673 --- arch/arm64/include/asm/kasan.h | 9 +++------ arch/arm64/mm/kasan_init.c | 13 +++++-------- mm/kasan/generic.c | 2 -- mm/kasan/sw_tags.c | 4 +++- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/arch/arm64/include/asm/kasan.h b/arch/arm64/include/asm/kasan.h index f7ea70d02cab..0aaf9044cd6a 100644 --- a/arch/arm64/include/asm/kasan.h +++ b/arch/arm64/include/asm/kasan.h @@ -12,14 +12,10 @@ #define arch_kasan_reset_tag(addr) __tag_reset(addr) #define arch_kasan_get_tag(addr) __tag_get(addr) -#ifdef CONFIG_KASAN -void kasan_init(void); -#else -static inline void kasan_init(void) { } -#endif - #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) +void kasan_init(void); + /* * KASAN_SHADOW_START: beginning of the kernel virtual addresses. * KASAN_SHADOW_END: KASAN_SHADOW_START + 1/N of kernel virtual addresses, @@ -43,6 +39,7 @@ void kasan_copy_shadow(pgd_t *pgdir); asmlinkage void kasan_early_init(void); #else +static inline void kasan_init(void) { } static inline void kasan_copy_shadow(pgd_t *pgdir) { } #endif diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index 5172799f831f..e35ce04beed1 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -278,17 +278,14 @@ static void __init kasan_init_depth(void) init_task.kasan_depth = 0; } -#else /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS) */ - -static inline void __init kasan_init_shadow(void) { } - -static inline void __init kasan_init_depth(void) { } - -#endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */ - void __init kasan_init(void) { kasan_init_shadow(); kasan_init_depth(); +#if defined(CONFIG_KASAN_GENERIC) + /* CONFIG_KASAN_SW_TAGS also requires kasan_init_tags(). */ pr_info("KernelAddressSanitizer initialized\n"); +#endif } + +#endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */ diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index e1af3b6c53b8..adb254df1b1d 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -9,8 +9,6 @@ * Andrey Konovalov */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include diff --git a/mm/kasan/sw_tags.c b/mm/kasan/sw_tags.c index b2638c2cd58a..d25f8641b7cd 100644 --- a/mm/kasan/sw_tags.c +++ b/mm/kasan/sw_tags.c @@ -6,7 +6,7 @@ * Author: Andrey Konovalov */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#define pr_fmt(fmt) "kasan: " fmt #include #include @@ -41,6 +41,8 @@ void kasan_init_tags(void) for_each_possible_cpu(cpu) per_cpu(prng_state, cpu) = (u32)get_cycles(); + + pr_info("KernelAddressSanitizer initialized\n"); } /*