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 EEDFAC54ED1 for ; Sat, 28 Jun 2025 13:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D5196B0095; Sat, 28 Jun 2025 09:25:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 284F16B0099; Sat, 28 Jun 2025 09:25:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 126556B0096; Sat, 28 Jun 2025 09:25:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F1CD96B0092 for ; Sat, 28 Jun 2025 09:25:39 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 74AD5BA5AB for ; Sat, 28 Jun 2025 13:25:39 +0000 (UTC) X-FDA: 83604881598.29.07A4963 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by imf26.hostedemail.com (Postfix) with ESMTP id 62ABC140005 for ; Sat, 28 Jun 2025 13:25:37 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="lOn+5d/D"; spf=pass (imf26.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.167.53 as permitted sender) smtp.mailfrom=snovitoll@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=1751117137; 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=L9hXJHuBvyYPVmVbLpoMFR4H07JOmA06RF+Wl4Z/7RE=; b=qU4xBfIl/O+BSSTsNrDVmLEpdcSrckrUnpZ3N+aYgxqLMeo1HUX9vOlUoxDcFr5CG2S0X1 xuw4BQAUjBQbnujyDDQ6TmUyqXqQ0c7YmeHoawhUqH8nnP4877c7WcI3F7kVaEveb/Owqw wecIWa5ruAcr7edNP0YXioYJKK23ltw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751117137; a=rsa-sha256; cv=none; b=h6xEIr53Oapa90xH3zC9Hoh4u7wAfSpoRrmUSqUJvvArhzPkO8q8s6rV4N9CiJBEwa+v2c eMorDol1zdmYRTaTVFHieK4Gu7edStnOkxToHytuMtjPMMZNb9Wy2p9cdU6vdT7uPHHtZd zu6Is/W1d9An/owcJKRPsQkHL3cyD0o= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="lOn+5d/D"; spf=pass (imf26.hostedemail.com: domain of snovitoll@gmail.com designates 209.85.167.53 as permitted sender) smtp.mailfrom=snovitoll@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-553ba7f11cbso3474215e87.1 for ; Sat, 28 Jun 2025 06:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751117135; x=1751721935; 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=L9hXJHuBvyYPVmVbLpoMFR4H07JOmA06RF+Wl4Z/7RE=; b=lOn+5d/D4jJVjvU6epWhDBn2sKzEToxN/82zqTGztOP2Vf59o3gUkARJElwqi7jfMh o9icyB8z6H1BqrY5XTSnfw7j9SKLAAWhM1ykBxURRUR5OIWq3uNHGSG63BIERSci1fVU oWNVCbixPozX5wVwz7wabkigZ4+KgpjN6ekAUorvUZ69WheQb6OGLkT73CRMv6KhbJqg J3bRjsz5WfGinUdfanpZO/2h4g6ZhjPc7Uwxm3sOd03yWZdijQge5ZCVl5Ltt7nRXcxM WQiE2B3u7N1vJKSaAN3GiOqkKuSbrMxP3ckKmoDdzvHXDuMmJ0VYwQ1Ck79M7Y/l9Yii do1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751117135; x=1751721935; 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=L9hXJHuBvyYPVmVbLpoMFR4H07JOmA06RF+Wl4Z/7RE=; b=G+dLo9XFHj4rj7fUwOZFJhrp0j5rzyLxiamgzMsTsZzPOpP8S2SmC8mDuJiwscYqbb t56D1Qdsx8tgC1sj5Y2Ji+Qg4jQgLpI9vO17PPCtF4zydkwM1sxFy0dl9pUhLU4RDO0V SCA4f3MEjwjqglu7wcrCEHQD34IvlP5FSkrn5lbQj/KWdPoUUVtX3S8ICPSDdl7uLaUb HJdqzpZvDHoIWivjKfPRkCUXYZbWUZZJ09xeSlbfa66X/lLodd/sOo5LWYqvuMq3zu+/ /VArVw2/x6WkBtLWU12mVnxJl3sc8ix2fKjUXoMKjolIaCEbr72Ldhp2sJxKO3zuNteS yDQg== X-Forwarded-Encrypted: i=1; AJvYcCWK/oghxNoyGqhMUCzxnfs/Kj5LOrBR0yy80iy+KnbkdubFd4hFhbib3UyngVpo0yn69C9tD5/8ew==@kvack.org X-Gm-Message-State: AOJu0YxseIXpe4M+vCZ6hvPuaepE2iDDC6m5TZlv4FkKq3vZyOk+vlyD gBu1Einm5m3MH88wgMT5oVHRdk5oJk3IUKAQIcZL15q7e1S8Ex0SyCSkXjmUn/xTLGa7nxfVlk2 n2lSnZs9znIxmbVeHqFC602h5aICJSY0= X-Gm-Gg: ASbGncvla8XunPK89c4MoOu5valuJi9c5lDHI0ZkJe2WNdojmVt8gdd1x0EBqLiwU14 lzv1FQYL5GknW2xSnXjYVLEEt+hyO7LsPYr1L9dTDHXLQY90luLeYF++CHtICsFPELWAtZbXyLz oTsgPcbd6Ln+uAK9C7PMMSSIinjj3xCOr7i4UPH1OI5H+5kAQ= X-Google-Smtp-Source: AGHT+IGcgqdYgD7HxbDyPqcYV3Heu4fL1zBBGlE2pOeLSvkf48pz8fpRePfbVo/DnCDwvNyc5box4+f/veOvw14SJEw= X-Received: by 2002:a05:6512:401e:b0:553:d1b0:1f1f with SMTP id 2adb3069b0e04-5550b817bf9mr2031982e87.21.1751117135042; Sat, 28 Jun 2025 06:25:35 -0700 (PDT) MIME-Version: 1.0 References: <20250626153147.145312-1-snovitoll@gmail.com> In-Reply-To: From: Sabyrzhan Tasbolatov Date: Sat, 28 Jun 2025 18:25:17 +0500 X-Gm-Features: Ac12FXz_1yZEfUGAygYOxkSS_g1GpWf3Y2t1PdPyYRlgb0h3dTvUyL8mVDVK8Qk Message-ID: Subject: Re: [PATCH v2 00/11] kasan: unify kasan_arch_is_ready with kasan_enabled To: Andrey Konovalov 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 62ABC140005 X-Stat-Signature: f5kzer8iujbyu8d4d4qujsxusj9a8jap X-HE-Tag: 1751117137-860042 X-HE-Meta: U2FsdGVkX1/cnJYVR/Q9pqFrhSpK4KNc1z+cDXBRtoycjtQrAD523R6gjeqpzA6huxBtnnEFlFjlCCI4++09b9vNU7z3vEwRq45gdc2cdXcl+daJLnMLTupv+b99OPLcSfRmYY2zKMcHAdX/XHriTLYg0yQyjJYx9aQgyRmXpfNOwtWUeoifTAbksqHS6BTOBQwI3ptPXt/v1YjLZDcSMEiToHdvAAos7mtb06bSVzIcNvYVwYr9xkKUYKchvpZCn8/fRlqzBsv5hEL70n+xadOPfA3tRblj2SK3UXd4XVsGv/2aYZrY34jQ1xjlO3uy9V+krjEf8hQ8hV90Xh8T8pqvmsAv3RhSjDVC5gOPKX8OXvC9KS4+THmxT7gzvWLmIrodc9qblfLDhvWuUsBFh62CQrdVOsVYNEqZ9nS/HB348deRk3uKlvaMVLfzsjI5kl5HA6xa1FsLYts3KAb8xbt8dWU4EX3YjLc3QDxtmfNll4Gu7yYtjdL8gJGrvY6hRZYEXxxayncfkUApL6N7ZJbLq9ebk6p9brBEHnMq6bGgCZZZBF7pVqbnO4Fw/YrSsX3GAwPhgNAYGvxyWiffzRVhTK+w1WcDqaGoQxxBiTg7IVmRB5Nq/FYYOB9NtxEjazwS4vrCuooYTOHxParzFWIuF5Ikx6D0XLDHk0J6soJN1GNPo8WJgeszBQXrE2e8n9cibesvrbuZ5/jzeQLYbb5C0/ge0pCvozThGhp7wiVfjPIB3aIEQXfvqjz9/G3LreNzDZfPG7lcXPrR4PirNoHppzbx33B27p1DH3nBnns6UZEkrX+PunfNowqBiWLjAEb5kZTVbze3col9ExV4nXPkuRczJfMhVWvNKjJDLCbBB0qa/BIGhmGRFZgev6RFouLoAoSq/NsVTA94AZvUNFXLE5PdWmVIUOTcl85EOhdORyeQ1dQSoSf2vd9dE8DMp+um6WDrp5OBWm0ejka AciQrkNW +MPndUz3/alPM/l4VrwighoUK7tbJlFTkBy+pyUWO53qFYFOXDGrZK5eV2WYV9L/6+Xe5pKd7UH5yacWILOfquzIWPZJVhFY2cIRZ4SZ91hGLsbNY9rOF/q2zi+jL0/bX7No3Xg3l4ANl8lwtJxIf2+74p0DPjSbGCEuFOKSeULbNrwNL3vfbWJVq+BklMV8YjI71gEuBWvQQ/Wc1wGJ6gpMT528b9PnuNhLivhjQVVSDjq4f+jq5fKXra8I2l/sN1SHmR+7Jn3CrzZGgSM3/80jZn9EEPUcAUrhQobX+1HvC3XTV+wBiZDxjc7pl0EOcmyCA3hHkWY9ke4skzUKIxNHdvs2BbGjYvQA89BeqV9r1MHHpMGY/4I/TLamCO4A4WlM9EC/G+FE9kMZybvAj1ypv3VuvbUCpET+kN8d5vIdPUWVeaZxt58YpwCnNFRNzJjDN/ETfSBnZhP18MaHnmiKe/ZdPyM8KjjErsgVR0ut6k6bF1fpiwk38KRQqFk32mViz2f6F6rz1+k9Z3hdTAC3xxw== 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: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 to > > work consistently across all KASAN modes (Generic, SW_TAGS, HW_TAGS). > > > > Currently, kasan_enabled() only works for HW_TAGS mode using a static k= ey, > > while other modes either return IS_ENABLED(CONFIG_KASAN) (compile-time > > 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() calls > > - 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? > > > In kasan_cache_create() we unconditionally allocate a metadata buffer, > > but the kasan_init_slab_obj() call to initialise it is guarded by > > kasan_enabled(). But later parts of the code only check the presence of > > the buffer before using it, so bad things happen if kasan_enabled() > > later turns on (I was getting some error about invalid lock state). > > And there might be other callbacks that should be executed even before > kasan_init_...() completes. But then for the HW_TAGS mode, if > kasan_enabled() is off, then we don't want to execute any callbacks. > > So maybe we do actually need a separate static key for > kasan_arch_is_ready(). But even if so, it still makes sense to move > kasan_arch_is_ready() into the __wrappers for the affected callbacks. > > Thanks! > > [1] https://lore.kernel.org/linux-mm/CA+fCnZf7JqTH46C7oG2Wk9NnLU7hgiVDEK0= EA8RAtyr-KgkHdg@mail.gmail.com/