From patchwork Wed Nov 4 23:18:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11883237 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 D399EC00A89 for ; Thu, 5 Nov 2020 05:02:50 +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 39ECD2083B for ; Thu, 5 Nov 2020 05:02:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NF265wBP"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EXdT/vIN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="wU1V8lsO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39ECD2083B 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=LLQH4a6cluNc1xFHfv9y4NeHGF+dWkuU0xDceWc2t84=; b=NF265wBPlJDCpTCtjR8GAzeak 0tvy/d/55p/WN0Boe3cA0czBOJrtLYQtPy7HmsaUS468+p+/nyF6tv5CcQ0AWnryxl8nPO6v9TgOo hmCItZf38/OmVkOdHSR5CgDwrxGiuWbWXx0NMXxsAODcxfDyk7rxQjb1aQ0Vzpkg5UnZt8jm9d0FD iym3od0rRXW6cDDujbbWT3nD5D2eT9fumu2IVD+95L+8rV3fqMTzhbPNu9+F07oZWfDvCm98nfdgL 1aV8zPSDotNmJ+qCQCDc8+Z2SydhXZkEqmniWsecto9tpAS+X/EfoT2xe1DEEgHR+Gj6ogkT+6sfh pkgfrOGOA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaXOc-0002vR-Gc; Thu, 05 Nov 2020 05:01:14 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaW5F-00016k-O2 for linux-arm-kernel@merlin.infradead.org; Thu, 05 Nov 2020 03:37:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NNpPR5seN/69hYJxiJpAYFp3W8/rjpHZNnZx8Fjl6mI=; b=EXdT/vINagSX7ZehZBCAJOGdIx GAopJ/dBSuT03085LY0LD1xIfv7lLHC9cvA16v14hatcGk7fvXFsJ7cG6PxSS5aEhx1/kChLnOtOt nH8BBi4Oaxx25vJTLjVLcsj3+KPRso/5vor78vWApiNRvXi2mccTWwVAeweN6Oqyoa/BAoxM5LAL/ DAtCfONdKlgW8/hYpzeWpXEpHYFRIwvKimbqjsK5PmXIkADuAKf5mrHf9mUw6Y5D6f2Tqe3JvZI2w kgXT68ai0b1vmowCmPQSAkk/lD2/NJjV/U5JEYjd+xv1X0VJdKFe2seX37nsHCVx4maxTTZPAhJBr 2mW1wqkA==; Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaS5D-00042H-MF for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 23:20:54 +0000 Received: by mail-wm1-x349.google.com with SMTP id f70so18210wme.7 for ; Wed, 04 Nov 2020 15:20:51 -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=NNpPR5seN/69hYJxiJpAYFp3W8/rjpHZNnZx8Fjl6mI=; b=wU1V8lsOAkGo3pNPWnHU6mO7WX0LIPMeVGitcBvkjWHQ8P6vVXjIUcGsKPT1RJTjau 82vzDogOhtwGxKyQCIdosDuHCtfsuIl7uxpWmo6Pn1TUvIqJxymwGsGAkaGODghphrjt HgZP0dpaZ6wF4lEJKbG8ohtm2c6atQyQF78H/NkBG1vcUtr5Y5yzdq0JVO5nCnfpXyHx U393yQI1+3HzEGRBKUSwd0OlQXiL0+BTnVXtEaJlK8ZJ1k6o03Arf/Z3ygWKHwsjc+4B VvQQCiuuqJ/qmAn6C3606noEHQleg1fRtvMeckYCAxYMb5iHuwTf4SqLihPvMbnhMrLr nWgg== 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=NNpPR5seN/69hYJxiJpAYFp3W8/rjpHZNnZx8Fjl6mI=; b=Wu2hByTmV9mFaON4ZpUoVex5Kr/1OwBeg20qU9S7RMITAZBAI/DVaHWZdZ+99lObpv 97sVjSMdHNHqQtJ1yBfAxvSX9ybGF3iTXnA9FRkCMnHXDVc3RpVkyE3jABwr0hkt4p4l TemeAu72GRN15kQROei1haZ8GLShl7bUrOrjpbgif81XpAlc2QI5HigcW+Pxhhex9knu Mn41jy409TmN74vFMAgUFF2NkGl0UGnVRvCEpuN6E80TqIr5J3a2WCYvRqHZpr+9i4xl Frnwqh/bR0lbdjg0FDgv7rPY8yIfGA2IEatpeYBwDa6ybCP9KVg/GSGOX+IZ7tuD3ubo JoiA== X-Gm-Message-State: AOAM533Rp9SoifROsRVqiRfsG63fUhjdXWdlDtZ31F04gwrzsLZr0EV4 lWk2i/gqcvzO86Upqr9CoXtwhD7m1r1tOOoS X-Google-Smtp-Source: ABdhPJzgqb8BbsD1ROqfJK4RnM9S+bQs5oY+EedW0m/ae73swJYXUEDAzaboVoA5x9IhiU9acDjl7af/hSCYzGUa X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:6405:: with SMTP id y5mr82984wmb.150.1604531987731; Wed, 04 Nov 2020 15:19:47 -0800 (PST) Date: Thu, 5 Nov 2020 00:18:32 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v8 17/43] kasan, arm64: move initialization message From: Andrey Konovalov To: Catalin Marinas X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_232051_966110_19EDBECB X-CRM114-Status: GOOD ( 16.29 ) 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 , Andrey Konovalov , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , 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 --- 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"); } /*