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: 11926467 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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 0ECE5C2D0E4 for ; Mon, 23 Nov 2020 20:14:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A032F20715 for ; Mon, 23 Nov 2020 20:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rWf39/QX"; 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 A032F20715 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=D+kztiv9Hja95aGVYeLyhsZ0ECN8oHBJLoiTKgQPvnw=; b=rWf39/QXsaCS/Yfit0e11C8je y+dndrdzS0K7o9DTV04kBFPk/nOrrL4iilflOIaGmNiQQoy6bcITFgrC/uAY5Vos0KYm2Jik1EDTA wY04qEkJ5DM+4MQcZiwNHg3UD4fhXppttpTZ0FbOD4K7kBePDERc7FK2VOyHj3HwL6V7LIsgX4Pw6 UvKzEzk/pubh9gF49/p/SN5ZqQKPXn05QfQxVxdQEHe/SCptitvN4LbgB43mhK+2nvgSCc2VvTT9+ QF08jvp73Dd3buZlarkrmlHC34QZ8g58CQExZEv90qIw+4N3f31qBk6e5tTx0NaFG+amxmLIro2ro HsjUrBSBw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khIE6-0001nS-0a; Mon, 23 Nov 2020 20:14:18 +0000 Received: from mail-wm1-f74.google.com ([209.85.128.74]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khI8y-00087f-N2 for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2020 20:09:33 +0000 Received: by mail-wm1-f74.google.com with SMTP id y187so154696wmy.3 for ; Mon, 23 Nov 2020 12:08:58 -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=Ep5qQMoWWu81Szbm1ued8vJS/O7+eeW1dgtBj+LK8arv2u6cJxXnMnGbos2J3146we wQc2bU56sVhSR7Z4MqfV9FdWQEgcZPYbhy3AwyTFAnu+wiXhsEdJYemQyQ0sRxEj4LLI EmZnb1RPuPPqJ9idma5sRKtBQgg/qRUDTHeM4WO6YtF9XBBm2/r6S14NhRh90TWVDnS1 uvL3cA5AadaYHkS232a5Ee54WZjiJUk2ypLdCwRVr1zBldB7RBjY7Gkg2D8d4m1VD/t3 JN+DyM/oLJ/p5c95WgF1ICDoxFPAKJcSI/IZ0Ya3cS/xZI8at5kzkgI0j4tLjTcGuYFE ECGQ== X-Gm-Message-State: AOAM532hcajYLOqQLG5PxVyUG4VPpT3GVUAZxTSjwL/F7FfgPB7m8k6H 3+2Qph573euytjYZUneO5pYT5RRM1Pkax5Hf 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201123_150900_844422_F4A9509F X-CRM114-Status: GOOD ( 17.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Marco Elver , Catalin Marinas , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Konovalov , Andrey Ryabinin , Vincenzo Frascino , Dmitry Vyukov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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"); } /*