From patchwork Mon Nov 23 20:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11926389 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=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 C1B39C63798 for ; Mon, 23 Nov 2020 20:09:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44B1C2071E for ; Mon, 23 Nov 2020 20:09:01 +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="WUct1EW0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44B1C2071E 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 96F4E6B009E; Mon, 23 Nov 2020 15:08:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F8F66B009F; Mon, 23 Nov 2020 15:08:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 749B26B00A0; Mon, 23 Nov 2020 15:08:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 3D4206B009E for ; Mon, 23 Nov 2020 15:08:59 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D0901181AEF1A for ; Mon, 23 Nov 2020 20:08:58 +0000 (UTC) X-FDA: 77516771556.16.tub14_5a183f227368 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id AB393100E6903 for ; Mon, 23 Nov 2020 20:08:58 +0000 (UTC) X-HE-Tag: tub14_5a183f227368 X-Filterd-Recvd-Size: 6924 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Nov 2020 20:08:57 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id l5so6217496wrn.18 for ; Mon, 23 Nov 2020 12:08:57 -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=Cs2ewUzarS5QIIwyBJDQZ4khSVYirNCbxYZ99CeZWdo=; b=WUct1EW0/45SbEo1Wd94pR9bmlHBk0spPS1gGG0tQf+aaoWQm9vH1OXWCs6I6zspkq kCKTmxoRoMDbXjmVa/YDqXgclS4VI/BAvEGLoEn9bBa7dIqOMiwmxKfnkdycYmPPVuZX /7qnoA3hrYbpjmU/BtmGDsCKOP4Bq1YUuEwRgYPBwTQ4KdyQtHyf6e1wwCgUP3/GkOFY s2QbI1yG5PTVhTX0uwp7PyqQAEEHOOpFjWOMl1/luGXi4d1nRa1face/qAUiHxG+9d75 xDTGrbzHzbs0CyVuq3vt87IOayaLdbzeymrLSaYyDR3RzPyKXqxvWGNqb+t5pQEwlt5n CEaw== 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=Cs2ewUzarS5QIIwyBJDQZ4khSVYirNCbxYZ99CeZWdo=; b=XvpZiHW1Fo4jiYcIgJJv52GQ4ULTHqjS7d92bXs9piNQHZRxa3nGEtduJMd5vxDIhf UwlfsGHQ6+rBpmywuevREQixW3v55cLgWibREPIT/ytB3xEIALZyq2quwMUFD4wCCHT0 3BC4BczuLXvd89XE5y2bd9k4/D7CwiSew0cBISppK1yksYtWtXn3uJjBFyo5Rqq+6j3s QUjlu/3SJJsJKHeBIIhuIA8LTcPFDFtlUZYJTOr+Owr8GGvFP3vEAh4n96AC7Yhgx7hM V6JS0LwqhwQWG2MRgjY2Nzb+43mOQpKx7ZzKRIqo3DfvXkWAzI//kP2z84xA1ZecaiTf 0V2Q== X-Gm-Message-State: AOAM531gOG2JfB3oF5yTkpokkJDFhaqW2PFk4GRaAwkCP11jS62wTXMw jWbVeL15N8cgyjuQ3n8K4nwt8Wzb5vm/Vb3+ X-Google-Smtp-Source: ABdhPJxqI6+90Bwq9lUGedXDGjcOQWQVZ0CvQ0BfvywQUPnH1rHLFxtB2q5xtYCqtqhg/oI7VUjbA6AJk53CtwNI X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a05:600c:2cd5:: with SMTP id l21mr605185wmc.182.1606162136904; Mon, 23 Nov 2020 12:08:56 -0800 (PST) Date: Mon, 23 Nov 2020 21:07:40 +0100 In-Reply-To: Message-Id: <29a30ea4e1750450dd1f693d25b7b6cb05913ecf.1606161801.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH mm v11 16/42] kasan, arm64: move initialization message From: Andrey Konovalov To: Andrew Morton Cc: Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , 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 67642acafe92..da3608187c25 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 64540109c461..9445cf4ccdc8 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"); } /*