Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp246598pxm; Wed, 2 Mar 2022 14:30:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA2PJ2h73h2t+CSIjikQhaN9IFlXZocCADUnuXAwSiwQFo4ONXWRf7bkLRhtWfcs8R3fnH X-Received: by 2002:a17:90a:4811:b0:1bc:c2e3:4568 with SMTP id a17-20020a17090a481100b001bcc2e34568mr1970267pjh.223.1646260224821; Wed, 02 Mar 2022 14:30:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646260224; cv=none; d=google.com; s=arc-20160816; b=luH+emEi0VBUCcXKeMLH+Lwlt0hQQ5z1870Br0JTabsRIx03YtApomCRtGimriMnNL 9E8BKT/BducS3puRPBoZM2hLEUbfVyR0YvjXUK1nop5tjF1LtX1q+N9zQdFZ/TKAw6Xk uyfPEE9qti0bhKjr5m3AjgKTGX8SFvZRT7XX6V6qNIyffkpI8/3g5MHL7s+kHtOoBb13 medRBCg3F+LwLnCRs042wOc6t8eO78c8w7Mi/g/VwxgOpukBj5TXokAMhxISalaztiGo AGu8+DXxLUNy6rqBQ+Xpt3GMHhXwj1k+E7lyMZvPA3QxYVmWvXHfdgyo235MZLYz0JFn CE6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xoA2paey3z+FS2agG9DA8SjKlQXnu1fJwhGoHYkB4f8=; b=scztHKXXRC8yQy6mvp9PM3IdCCB15dJkYFFE4YHJZMVBR0C1Wz4ybmGm4rK6avWu2u ZnqHu/VgL+fPIqfF6NH1C0cWWftgXM0CSmmYjQAcOeTv5NVq/myO3FcrgpqGW2Lnjk+d EXBXrQBj+jNh1+eTMhf3AxUJSefErdfmaqJz6nr+omMBNkSRkncXh+eRyizzV0hG/DBd nqRV43Kb3zNp7bVIG5SE2svAdMw7NJAHjfTFbbsh6ZRtld2Ev6mVjNcxXTPd1ues8oUT VT9wytQKpcD7malYKgi1TkSY8AEqw02aygeW8T5Vg2r8MUbELCZ7F8Ggza7V4ySR9M0m qVZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eBQyizDu; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id nu14-20020a17090b1b0e00b001bef81eacbesi217825pjb.69.2022.03.02.14.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:30:24 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eBQyizDu; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 588F8E98D4; Wed, 2 Mar 2022 14:28:41 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240114AbiCBQk5 (ORCPT + 99 others); Wed, 2 Mar 2022 11:40:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239761AbiCBQkt (ORCPT ); Wed, 2 Mar 2022 11:40:49 -0500 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC92CF385 for ; Wed, 2 Mar 2022 08:40:04 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1646239203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xoA2paey3z+FS2agG9DA8SjKlQXnu1fJwhGoHYkB4f8=; b=eBQyizDuePbrr86tYNcUx/vFZwzzE0ijJKaaqpwjJdXWroQKed3pkHWU/poH1HtMAoNDgZ cb82oWToQ1vY0PyoZz0Jrj7+JifUkj6liyEZFlH4Lofk4SwLHmtre/inkPuJwII6Tg4DH8 yuNwZUCiYKxlOKZ4I+P7bnliTUPkhVc= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 21/22] kasan: move and hide kasan_save_enable/restore_multi_shot Date: Wed, 2 Mar 2022 17:36:41 +0100 Message-Id: <6ba637333b78447f027d775f2d55ab1a40f63c99.1646237226.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov - Move kasan_save_enable/restore_multi_shot() declarations to mm/kasan/kasan.h, as there is no need for them to be visible outside of KASAN implementation. - Only define and export these functions when KASAN tests are enabled. - Move their definitions closer to other test-related code in report.c. Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 4 ---- mm/kasan/kasan.h | 7 +++++++ mm/kasan/report.c | 30 +++++++++++++++++------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index fe36215807f7..ceebcb9de7bf 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -267,10 +267,6 @@ static __always_inline bool kasan_check_byte(const void *addr) return true; } - -bool kasan_save_enable_multi_shot(void); -void kasan_restore_multi_shot(bool enabled); - #else /* CONFIG_KASAN */ static inline slab_flags_t kasan_never_merge(void) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 9d2e128eb623..d79b83d673b1 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -492,6 +492,13 @@ static inline bool kasan_arch_is_ready(void) { return true; } #error kasan_arch_is_ready only works in KASAN generic outline mode! #endif +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_TEST) + +bool kasan_save_enable_multi_shot(void); +void kasan_restore_multi_shot(bool enabled); + +#endif + /* * Exported functions for interfaces called from assembly or from generated * code. Declarations here to avoid warning about missing declarations. diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 7ef3b0455603..c9bfffe931b4 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -64,19 +64,6 @@ static int __init early_kasan_fault(char *arg) } early_param("kasan.fault", early_kasan_fault); -bool kasan_save_enable_multi_shot(void) -{ - return test_and_set_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); -} -EXPORT_SYMBOL_GPL(kasan_save_enable_multi_shot); - -void kasan_restore_multi_shot(bool enabled) -{ - if (!enabled) - clear_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); -} -EXPORT_SYMBOL_GPL(kasan_restore_multi_shot); - static int __init kasan_set_multi_shot(char *str) { set_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); @@ -109,6 +96,23 @@ static bool report_enabled(void) return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); } +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) || IS_ENABLED(CONFIG_KASAN_MODULE_TEST) + +bool kasan_save_enable_multi_shot(void) +{ + return test_and_set_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); +} +EXPORT_SYMBOL_GPL(kasan_save_enable_multi_shot); + +void kasan_restore_multi_shot(bool enabled) +{ + if (!enabled) + clear_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); +} +EXPORT_SYMBOL_GPL(kasan_restore_multi_shot); + +#endif + #if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) static void update_kunit_status(bool sync) { -- 2.25.1