From mboxrd@z Thu Jan 1 00:00:00 1970 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 F33FAC7EE39 for ; Sun, 29 Jun 2025 20:05:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C3066B0089; Sun, 29 Jun 2025 16:05:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 173616B008A; Sun, 29 Jun 2025 16:05:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 062A46B0092; Sun, 29 Jun 2025 16:05:38 -0400 (EDT) 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 E25566B0089 for ; Sun, 29 Jun 2025 16:05:37 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3C38310415D for ; Sun, 29 Jun 2025 20:05:37 +0000 (UTC) X-FDA: 83609518314.06.8B535F3 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by imf20.hostedemail.com (Postfix) with ESMTP id 5A6BB1C000D for ; Sun, 29 Jun 2025 20:05:35 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XuWtTIkf; spf=pass (imf20.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751227535; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qpjVZvBcIo5G28UGMNZaBkJZF6ITVDpFyOxvjBVjrQo=; b=63QU2gBYe8QVnsdfEOsrLsTCnXwU4B115BS2NDaPwG2bwHvzpy3S25Tf+2pXgCxp/FwQRL ahBPX9OL7RqMj1TrRdo1HvvcXsjmiWhOEuZP9LiIFD/gv7b/nk0EEcowHTAQE8Sg/Im262 jg8ago/e8sM/ask9yCD4gxpo/QzWjb8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XuWtTIkf; spf=pass (imf20.hostedemail.com: domain of andreyknvl@gmail.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=andreyknvl@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751227535; a=rsa-sha256; cv=none; b=whwdQNdoWx6wGzI+kJZI6xAtLYYVJHBNQsAyX/OMztW8HRKR0nyW7MIc00jW2XVglctplp AF/tzjECSGrfZRoHkIp6QhSqQkyPbH+vQXjdUjMxTaAM0a3Ph0PoeqJxAN6zS+lN6jsb2c DvHWpASD8i3AsEYpvum0JWDEemYFWv8= Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3a6d77b43c9so1290890f8f.3 for ; Sun, 29 Jun 2025 13:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751227534; x=1751832334; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qpjVZvBcIo5G28UGMNZaBkJZF6ITVDpFyOxvjBVjrQo=; b=XuWtTIkflBe7yoY5+h3z+F4QRVFmkHEtuahQps8c4RPRox2AKCiaRAcVpID1ijlamR swRSpU+nK1j8bC6goxm8k61ZUTjQILVtrS4uQ2iav+G8acCBk+Gv7TxahcTqSihj7IKi +L7bYV0IAsT0vgV/yoQmRGSCbIq5zkmAz31oI7Xy3lolj4tcSXysmzXHNj0rDm2l1vyG YiayPoQla9IZPcMkiHE9Y5UmmaoN9Y9S4kxIG0THrlmWcfHjm+EUavCvkcawXqCOT42Y Up+P2IXSQUPvJwPh4zFdwL1Zf7lWalh9JHj0URIWVM5ZnjIkZHTEckZdTJzRt7hdXSC5 7StA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751227534; x=1751832334; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qpjVZvBcIo5G28UGMNZaBkJZF6ITVDpFyOxvjBVjrQo=; b=hnMRDAWsMzk8hpE39nFqNMxlzhcy3VCb5InV5r91BFQSTFHe7hCNS1JHzZpzU/I38Z jUrzAhXrPfuL47BqLcHQ79QhUqcY9ISpnmunkr3Vvg/xyyl3QWK5fLEOfqjgumgLs8fG hwDFBPdus6Ar222Vhm0q+5ANC4dd2+vMxkyQGvu52wsQAYlBsnK04SNMAitVur8x2dl4 5H2z0lwvFwUUr+c1zCqBeOk7i3+6zDAITWpSG9J5dWW9HRXRkiF6WBAKo5sVACHWfyAy bTYBdsR2ebtVliX0ZnCRBwmtcwLNBuH0sfm+pbah/DQghkrtEPvlQwk9iKsBtY19g8N/ +jBw== X-Forwarded-Encrypted: i=1; AJvYcCVfyxm7nFtFF1GobMtP+Wy52PIoJTg3Lo38S43h7P1ogCd8XJ1e5zhCFfYrGMt1LRo7m+NEdDAdKg==@kvack.org X-Gm-Message-State: AOJu0Yz7S+2Kx5/4wb9/P8shEI8FDSNazAKCsaNJx5X/1ADjYZ5T3+Dp B0OfmLDLTBZaUTxJG08eDTSHPLsTkLeVnr8udI7vAK3C/cZ5uHV9FeoGxjVDD8T7+C6MdPVRubV mPy24R0bXXcxmf3iam5Vxqe3fAr9AKn4= X-Gm-Gg: ASbGncvQSVaeb4bbnIYquVvYeku9ayO+Igr2vfp0qEzSWLgsN9wRUjvrNiVihQUEbIo liA2l/HZxNnBFDejM6doJFtVlZqdzlRR0krk2i66KMBIoi/nC1bXSE162o1+Oksgh+iiD3xWuRO /39INjJkrksyP10U127sN5aMBXiZsUv0zDUQBo4OrGukLBolFrjV9+iZw= X-Google-Smtp-Source: AGHT+IG9Jnr7utU7Trd4lqTg8GWi9uRNVbru2WXxMPFleBJfH4kInx+LP9kDmy2SL/eaM5dKaQqnO/o2Ok4MjECqA8k= X-Received: by 2002:a5d:59c7:0:b0:3a4:fc3f:ed28 with SMTP id ffacd0b85a97d-3a8fee64fafmr10710844f8f.29.1751227533501; Sun, 29 Jun 2025 13:05:33 -0700 (PDT) MIME-Version: 1.0 References: <20250626153147.145312-1-snovitoll@gmail.com> In-Reply-To: From: Andrey Konovalov Date: Sun, 29 Jun 2025 22:05:22 +0200 X-Gm-Features: Ac12FXwSsH6fvJE1vEp59zDWu481tFenq-ukDXNa3gyvAGzFlMqgNHF8VfcuM6Y Message-ID: Subject: Re: [PATCH v2 00/11] kasan: unify kasan_arch_is_ready with kasan_enabled To: Sabyrzhan Tasbolatov Cc: ryabinin.a.a@gmail.com, glider@google.com, dvyukov@google.com, vincenzo.frascino@arm.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, chris@zankel.net, jcmvbkbc@gmail.com, akpm@linux-foundation.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, arnd@arndb.de, rppt@kernel.org, geert@linux-m68k.org, mcgrof@kernel.org, guoweikang.kernel@gmail.com, tiwei.btw@antgroup.com, kevin.brodsky@arm.com, benjamin.berg@intel.com, kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-um@lists.infradead.org, linux-mm@kvack.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5A6BB1C000D X-Stat-Signature: tj95w6aoxg3u7rcezje85fogdub13pmu X-Rspam-User: X-HE-Tag: 1751227535-438895 X-HE-Meta: U2FsdGVkX1+aThBBDeML4jNOzCHFnME47GMkiZBCJX2acludAZKCBBOWYc8rIKU/eu61rDPxElkW44PATqWW3vN0YMzn8P0KYwZX2YiNREcfdIHvpbdpWGrssMqBBGBIPwEF/qJ7gvFdwjC6LhMJE7jkifKx5IOS5sP3FT/k4m9zgKZjCsuXPUmkbBUFar/IDrAwnm0bs04lt6bJGL1hfs//a1HpOdxpTdaznMQAe+5lM4yAVVCcOhYk14InppgHdDy5e6LWWzwHRuqspfHNAIt8fB3CTvjayPTlhIzc6RxrRPcJscM0AwfAC3mo2aHwjgGYbfiC1kKpKlPGy9Lq/FBeOK8qb1+1npkf3l+zpb4F3dWv8Pj/l2fRFn5aV5re7umi31y8ogaouVlBHY3Hvg+6wZSEKWttPFhw9aiRdfXAVdQm2TLPs1nzgNvV1ftV2oM1Cfddq6IwwfPh1gOPGHW3XzxmtVvYrLOCznpbpuqbDmGZTMpQcXGRbZCsHGtgPOqhqk9+Phek2vtLtb0ZsUm4uFftmO0mx85NnB7td+1ArnKeSLeWFbuN2z1Gdt7pPEmfbwtFcWIHDm+B/qkweS4l59HgHDAKI6FTPDmcaK70qpjdChSZ9Sd0SJxaeWD7+kqOyhgc/bU2X32YxtFDiD2uVHUXXEwxxYn9LL6c2vwBilRwaaDYKSDUgyokFwRnUzP7EhAcO/pR3PeLr5REZ5LWz17XAQTaRDYUlsjUECSzrn7BvNQD/0buI8MxK/ZK2HCO/wch/SWkvCVVvMndec7ErmT0iXkYztMenLCt5jgXEhXE+cchDT4AMEnyct4Hom/zwzyEKtpBZ/z7aUDd+TYQcQ/Le4v9KtaMUSLPg132zeFfcn5GB70r/x4ZP3GAPIuqk4VpUmGQ1qia0RcMfqBD4IVKJd+yCuaSRNymPfGk8a3990jnxFSTh3CLMsLRWJYZGo0hTcRcytL/h/b RxxJCuIK 7L/oQligWd/E4AGS0CwkfDAaUaUPhWyXMK7BHU+/9uVw+93igvqbXxMVA8au2iDDtOw47nWVAIrkEXLlwwU3FHT/2T/zjpxDGwGABp3pLtcASPuw0D+VOp7zOpvH5pCAUy0OrzRi+P7asyE6wQ/K/Wg3pleTaAE1FQ/nDaZajXPmkpZTppHAss0Tl6BtZBEnwJATkvJsbxLjzV8c6zJ8TBMcsTF3UO3ZihEQjYPBpFxpMMhE9MxRhBfGZ971SSecytzm7TZqcJzKCfyAGJJZqJIwl7Nsw74eqWR1Bm7pGrfgwp8tMeWjH4AVNoWBYjH224H0jQPY83rs1Oqh3avbxlxNFWf9grjLdkpCdYuBcnXoT9vQ/GiiUPNSakw57b/uRSQILbgNXDbQIifpqBHHoOqx/kuNB48/tzo9Zph0XU/wDx3NUNilEAIIn9+IRaiI4LATsnIWMket4CDEuNRQ1LwqPjNZ4QRfqycTdaa7xWVBIBB0= 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: On Sat, Jun 28, 2025 at 3:25=E2=80=AFPM Sabyrzhan Tasbolatov wrote: > > On Sat, Jun 28, 2025 at 3:57=E2=80=AFPM Andrey Konovalov wrote: > > > > On Thu, Jun 26, 2025 at 5:32=E2=80=AFPM Sabyrzhan Tasbolatov > > wrote: > > > > > > This patch series unifies the kasan_arch_is_ready() and kasan_enabled= () > > > interfaces by extending the existing kasan_enabled() infrastructure t= o > > > work consistently across all KASAN modes (Generic, SW_TAGS, HW_TAGS). > > > > > > Currently, kasan_enabled() only works for HW_TAGS mode using a static= key, > > > while other modes either return IS_ENABLED(CONFIG_KASAN) (compile-tim= e > > > constant) or rely on architecture-specific kasan_arch_is_ready() > > > implementations with custom static keys and global variables. > > > > > > This leads to: > > > - Code duplication across architectures > > > - Inconsistent runtime behavior between KASAN modes > > > - Architecture-specific readiness tracking > > > > > > After this series: > > > - All KASAN modes use the same kasan_flag_enabled static key > > > - Consistent runtime enable/disable behavior across modes > > > - Simplified architecture code with unified kasan_init_generic() call= s > > > - Elimination of arch specific kasan_arch_is_ready() implementations > > > - Unified vmalloc integration using kasan_enabled() checks > > > > > > This addresses the bugzilla issue [1] about making > > > kasan_flag_enabled and kasan_enabled() work for Generic mode, > > > and extends it to provide true unification across all modes. > > > > > > [1] https://bugzilla.kernel.org/show_bug.cgi?id=3D217049 > > > > Hi Sabyrzhan, > > > > Thank you for working on this! > > > > One aspect that is missing from the patches is moving the > > kasan_arch_is_ready() calls into the include/linux/kasan.h (this is > > not explicitly mentioned in the issue, but this is what the "adding > > __wrappers" part is about). > > > > Another thing that needs careful consideration is whether it's > > possible to combine kasan_arch_is_ready() and kasan_enabled() into the > > same check logically at all. There's one issue mentioned in [1]: > > Hello, > I've removed kasan_arch_is_ready() at all in this series: > [PATCH v2 11/11] kasan: replace kasan_arch_is_ready with kasan_enabled > > Is it not what's expected by unification? I guess the issue description diverged a bit from what needs to be done, sorry about that. The core 2 things I wanted to address with the unification are: 1. Avoid spraying kasan_arch_is_ready() throughout the KASAN implementation and move these checks into include/linux/kasan.h (and add __wrappers when required). 2. Avoid architectures redefining the same kasan_enabled global variable/static key. Initially, I thought that s/kasan_arch_is_ready/kasan_enabled + simply moving the calls into affected include/linux/kasan.h functions would be enough. But then, based on [1], turns out it's not that simple. So now, I think we likely still need two separate checks/flags: kasan_enabled() that controls whether KASAN is enabled at all and kasan_arch_is_ready() that gets turned on by kasan_init() when shadow is initialized (should we rename it to kasan_shadow_initialized()?). But then we can still move kasan_arch_is_ready() into include/linux/kasan.h and use the proper combination of checks for each affected function before calling __wrappers. And we can still remove the duplicated flags/keys code from the arch code. [1] https://lore.kernel.org/linux-mm/CA+fCnZf7JqTH46C7oG2Wk9NnLU7hgiVDEK0EA= 8RAtyr-KgkHdg@mail.gmail.com/