From patchwork Fri Nov 13 22:15:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11905011 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 97021C4742C for ; Fri, 13 Nov 2020 22:25:40 +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 400C1207DE for ; Fri, 13 Nov 2020 22:25:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MF7c6FNI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="LT5CFhYH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 400C1207DE 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=sN5CJacP5g7zwGPgZTwk16oU+aG6q6rX7WCAvvLJg54=; b=MF7c6FNIF06mLCsoAYLYpz5i8 qzsib4GtszpV2NWterQxAjvj5DhRpSuTBDltmJssD+zvtbc5qxyurNY1tcsXeRVJYdOmNK+P13U2p Q6viVXb9hr6mzpoxjnoE7rLdLY6/tCq1rZRKklYzePn5NSBnAgtK67I3HGBau6t2GrBUp3KMDOHfA HsPSkgQL2VgOFZaXpcLwGHD8jd4nkWIZAncX4yimOCnIJigf73kpZdlPcVRwjqF1dkQvXh5xweMMD rJ+sBShElYsOzvSPhCiEt2XDvmwzgr4LvFNDWipAdZLnZv/NZYokFssX4vz+mQd19mRdHJosfXfis kIMRs2D/w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhTr-0002ut-6W; Fri, 13 Nov 2020 22:23:43 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhNJ-00005A-1X for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 22:17:17 +0000 Received: by mail-qk1-x749.google.com with SMTP id b191so7557928qkc.10 for ; Fri, 13 Nov 2020 14:16:54 -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=9CcY7cnQj8/ZsaLGH95ZEDucryFMFL6l1gyKldTtU/U=; b=LT5CFhYHaN8omWk5Uxml6lUvURFHI0+sBfS54fERR9cl7aj5uCi6KAEnNmK8+RcWMn orCocB9w08pWBpuLAS5lYsnFtkwJrX/d8CIF7I203aWNv9OxGPQkdNFzJEVC89GXcByC h5/FNp916fJGFkKmdAsElpoh7Y9VwSiRSxV5fAN8VOO6WvalHa/gbFxAJJ4XXdHYdYsV QSYnG4Dcn9CFEijD12xw9hq7NK3VzoJPBDRXfTs/YfzCn/RP72oBX+Z3NeNpk5q97Dz4 zwjGtK/wKGqJ24ZTJy/ao6jjUp/MbxBvCGk116FNIFy2dyI+dJMNvZQUKve+Jqn8QVTI Rm9w== 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=9CcY7cnQj8/ZsaLGH95ZEDucryFMFL6l1gyKldTtU/U=; b=ZRmmW7B/DHPFGq63McXL0430l/tHbXa7B91oeNUAyFXc621EairXpSgema5srSGrxS AyB/Viqo+9fye9zFh63SCbSc2XGz5Jkfa/YhtxjJ50g0kqDfSttM9FzdBa/+1qLCSL0Q rRy384JC4w7kGO17zbbZmNrgjxpt31fGefHpT5PES6yvdICd3GXiTh7gJhtNWqpmKOKW v1K+6gMBC8ZTzCVP3QPeXl7SD8V2rAwxTIZuJMPgkh27Fy9r20u83gmNf502mpFAfRZg TxczHY5c/yfyS6Fs11ZmPzUMDioeexXB7OuVDactA4diUm/eDr1Fq8jRx+Nd/dSxeJnS vrgQ== X-Gm-Message-State: AOAM533vk7fUjaSD6ODKfbYst6sXjBUXqE0CZCP1lgewyjbmkNVUpoDH tWYK3m5v/gyL/j0ZZ0m7524gsAT6V2YQ9vSS X-Google-Smtp-Source: ABdhPJyiAX644hwQFHmDLOuMlOvFdeD1Qx/fNQM4q6Bp+omGxRcM85yv7R/X+J3UtiGUFsdzMjYeCrG67ukgzQc7 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a0c:ec4e:: with SMTP id n14mr4382317qvq.7.1605305813183; Fri, 13 Nov 2020 14:16:53 -0800 (PST) Date: Fri, 13 Nov 2020 23:15:44 +0100 In-Reply-To: Message-Id: <031e7a7e501534c0ec5d77f6733d63ac56513d1f.1605305705.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH mm v10 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-20201113_171657_198176_DED21E9D X-CRM114-Status: GOOD ( 17.10 ) 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"); } /*