From patchwork Thu Dec 21 20:04:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 13502602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28FA1C35274 for ; Thu, 21 Dec 2023 20:06:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B47C66B0098; Thu, 21 Dec 2023 15:06:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD0946B0099; Thu, 21 Dec 2023 15:06:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 971EE6B009A; Thu, 21 Dec 2023 15:06:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 832656B0098 for ; Thu, 21 Dec 2023 15:06:08 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 45F501A0C9C for ; Thu, 21 Dec 2023 20:06:08 +0000 (UTC) X-FDA: 81591906816.20.4F93B9A Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) by imf22.hostedemail.com (Postfix) with ESMTP id 94FA3C0012 for ; Thu, 21 Dec 2023 20:06:06 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UQy5FdaO; spf=pass (imf22.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.180 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703189166; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FJl4ImE4TRrDXvrAPN+dS4cgTUzwQEr6h+ILfia+IPo=; b=8rC09zks98B2ls0WDRR62Ha+cjIY/cYbNlyH3oD31JXfnKSMsRRKh7cWthtywKVsbRAHbF 8bbbJGjZTmU82pNlxihyJK0AZWGKtzFRfMNehw+OzcII4fZYwNTvRpvaG9qFxvRcqaAXxz 4a4tw8V0tgoNgP6KCsy3Qe71fmfvQIA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703189166; a=rsa-sha256; cv=none; b=BX1JLtmWwt7PYw4JSBAhCUyQTxC7oHzfRqlcLpLRmNpxqwr2LWKCr3sEie0/8Uht6oCSK1 diyP9U0nK2R09+HvqD4xTGxLmJfZSjghgIsKBbY7hG7OCqFzn19kaUvIfW8F1ZzsMib+by dWYMZFbEa6luOpJZgzwZbbj4Q10aNJg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=UQy5FdaO; spf=pass (imf22.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.180 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=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: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 94FA3C0012 X-Rspam-User: X-Stat-Signature: 9f6ky3zn4wpxn7wskugizndjqqgruzy3 X-Rspamd-Server: rspam03 X-HE-Tag: 1703189166-894388 X-HE-Meta: U2FsdGVkX186+WA13jMN1V9Njnk/VJtcnaErqo03/d5AXkoEqCMOKRiu4urSkLVFcmDaNrEy4NgdxfgODE/agmXROcvk32yYc1mSXcZGHrh1wa8Zqi+o7FYR/w9cM5bwt1khV9rTuQDHQ0Dd8FHPkXuZLPOUr1TFFuNVaUA+8+xQty2KRVoeigeW6ifxEENEtZZLKt2W9Q3oFiD7M/ZpeAY+kv3YdjH8cgQAT0dfrG6AhV8yuKXMaiSLkVXUrBSacgCuHrPlVC9S19n30p70bwQtBVD2+VeLjQIACTjKbB3bBsdSxSPNHNgv+mz3IxtALpYoPKQfdilYVh2vQm0RLUv6XHpsOW87Sfmtnr1Wthork7O21FC3xXrAkAVIXpAL6M7tUFW+LQd8ZMC217w2WUra0Ybc99iDiuDL/Uv5lYx7a1xYhhH+8dzuEr+Z7v6bh//esoKEJHcEwM5bQcTFcsJfgm+b5bFle/u0P3nGuoJnwet2qvbwf2k52FXuqeH+tQTQ2W9ZuhAgxV6U/1K4rzeWUAoMy8n6D736Jg85+idAdXGeeb28tV/RtAYhVZffJAC3vUsurw2MIUY8eJ3HiXuxsS6/n0866qD+XwTsHFRVJEfxMKE0EgwEnH1nGmlUNNYBdtCxSYFiywDywibDvTtWd/KuNy6LnneyYy8T6O5WFsU87Q/YF0oTa9ENoobfsINGU57KZKK6Hp9JV+PO3IJQ8YpJWrcv8ChpCKJV3rky1fNXXu5kXhZfY3tVGbOleCZ065pvFhClTJo5YyM4dtEgDnJX/lbJo+czBlh3iuYB85l4cvK3tPbGModul1pcB3kJgJZa9DaaXJULsRBQ0iP5GoWeYGJ8Gj73HdBC7Xiw1v1W21xQj/rOm8Ym4+Zc78EHEu7zRTe9bGvxouJGgQHiG2M0znHE8at4xiVfXqBeXgkGsasSJv1Kd+8BblxMzNQ8JMYQ76RvToy4VAJ gFcbC+iN RychmduLpFzNkNxAYB+iddO5r5dLj/Lb+d27Gx9FQ7zTBh8B+ib60ZhWDCX2fAQ+BkwaR5ibMU8wY0aTK121dccYYdHOhv9X7TTpDdlquczGKEHGms1iUr4Jfl+bb41yUYld4qNZ9A5/YwzKn1K/7h18P2h+yxz+NY8Ef/po5o6Du1f7pktlpKyMfisRImg61UBS6iPQrRTI6JIkDxmlQHDmUOg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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); }