Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp389569rdb; Thu, 21 Dec 2023 12:06:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHY6xhAk4UO5HhR7TSRE6NGm5GuLHCSkwScMphObO3yVJaaf9HDbbI8jvf2DjejuwYWWhUR X-Received: by 2002:a05:6a00:124f:b0:6d8:50d1:aa48 with SMTP id u15-20020a056a00124f00b006d850d1aa48mr266501pfi.16.1703189207894; Thu, 21 Dec 2023 12:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703189207; cv=none; d=google.com; s=arc-20160816; b=Xu2/p8OP5cd+7ZqTtDlmGn51NfaNCu9a366QkKKX9Zz6qHUmyAkPkZAM6U8/0KmhUa 5e8VA+++pAnfUpIG1NiUSCMvj2AQpFFcojJbq/A+Q8D/zGtfgq1McwDRqyxXBWW9jhCz WQ58uc+E7B6UJkjjLRS/v2Dzw3gY/PV4Hf+J/CllfYf9VjEtobgKrioXSeal8UQk1hfm xGmzIzHwDYQaZQ9gmuljdhbhTG1sozMZiPA2xmGyr2A34Mps37EAwCk/i//GmOcTBFKh sV7yhZ93cAhWitlMvMeSs1BS5F02L+lYaF6EWzqQ310yF69kxv1fyCv6F/YbtOxZdZQ7 Hwcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FJl4ImE4TRrDXvrAPN+dS4cgTUzwQEr6h+ILfia+IPo=; fh=GyTEpUCUNPwsl1pqA0jDPXgvja+iZTM9USlQd9sQtQg=; b=TCiinSIzr4Yd0GwvzJTnyKmea6GuDRTaAUX1FVGr8W1fIn7777bEv0yaTbtaQxGcIX +DVu/c8T1EKZAZZpB7XgmKXcxrSp0m3yY9p3GZlMLFHLR9/iSzPRvh2dAn13+r1giywq /vn11gcjm+JKzGEE5ZvxsaclSv0bqBC1hG3sWgnbIVJdW3HOvKQ5hZCkZMnJRTaE3nmL d+KIAuHiLdW11/oHtwSb60uwGA+3MCe3TFP0CNZolyDuPxx00yimSHKu9+s5jhUThQAr iWsa5S68Q52DE4o18/BiuYLAihZcGR4/7h7OjoF/lEc+QP9jzIZLi5WCfKNCklASzfpb XhsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=UQy5FdaO; spf=pass (google.com: domain of linux-kernel+bounces-9025-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o13-20020a62cd0d000000b006d9847ec3afsi7870pfg.316.2023.12.21.12.06.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 12:06:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9025-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=UQy5FdaO; spf=pass (google.com: domain of linux-kernel+bounces-9025-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9025-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D3370288F44 for ; Thu, 21 Dec 2023 20:06:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CE50745D4; Thu, 21 Dec 2023 20:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="UQy5FdaO" X-Original-To: linux-kernel@vger.kernel.org Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E833745CE for ; Thu, 21 Dec 2023 20:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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=1703189165; 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=FJl4ImE4TRrDXvrAPN+dS4cgTUzwQEr6h+ILfia+IPo=; b=UQy5FdaOJP3WHcVUkGmBl3aQkcqo5p6PbagnBT8wp0ljLIpod/Ojsrg7YfgnIjF56yHZRq Hho7BHFtctI8tiFKBQkJ21sW2wiU4BcM7mHrjBDpphYej6wGMhj1TMy2nV0GXg97lpUgq8 tU7rBZD5CJd5flB9JqJlXxWqDy6GX1E= From: andrey.konovalov@linux.dev To: Marco Elver Cc: Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 07/11] kasan: respect CONFIG_KASAN_VMALLOC for kasan_flag_vmalloc Date: Thu, 21 Dec 2023 21:04:49 +0100 Message-Id: <3e5c933c8f6b59bd587efb05c407964be951772c.1703188911.git.andreyknvl@google.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Andrey Konovalov Never enable the kasan_flag_vmalloc static branch unless CONFIG_KASAN_VMALLOC is enabled. This does not fix any observable bugs (vmalloc annotations for the HW_TAGS mode are no-op with CONFIG_KASAN_VMALLOC disabled) but rather just cleans up the code. Signed-off-by: Andrey Konovalov --- mm/kasan/hw_tags.c | 7 +++++++ mm/kasan/kasan.h | 1 + 2 files changed, 8 insertions(+) diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c index 06141bbc1e51..80f11a3eccd5 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -57,7 +57,11 @@ enum kasan_mode kasan_mode __ro_after_init; EXPORT_SYMBOL_GPL(kasan_mode); /* Whether to enable vmalloc tagging. */ +#ifdef CONFIG_KASAN_VMALLOC DEFINE_STATIC_KEY_TRUE(kasan_flag_vmalloc); +#else +DEFINE_STATIC_KEY_FALSE(kasan_flag_vmalloc); +#endif #define PAGE_ALLOC_SAMPLE_DEFAULT 1 #define PAGE_ALLOC_SAMPLE_ORDER_DEFAULT 3 @@ -119,6 +123,9 @@ static int __init early_kasan_flag_vmalloc(char *arg) if (!arg) return -EINVAL; + if (!IS_ENABLED(CONFIG_KASAN_VMALLOC)) + return 0; + if (!strcmp(arg, "off")) kasan_arg_vmalloc = KASAN_ARG_VMALLOC_OFF; else if (!strcmp(arg, "on")) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 5fbcc1b805bc..dee105ba32dd 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -49,6 +49,7 @@ DECLARE_PER_CPU(long, kasan_page_alloc_skip); static inline bool kasan_vmalloc_enabled(void) { + /* Static branch is never enabled with CONFIG_KASAN_VMALLOC disabled. */ return static_branch_likely(&kasan_flag_vmalloc); } -- 2.25.1