From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7ACE2DFF3F for ; Mon, 25 May 2026 18:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779732106; cv=none; b=hGBs5KOXBRITd27gIsIffIdZt/14wetxx/v4qHvoDMANDeRW1Tn4CBScfFffewG0dCXvyICDN9SMnA4WUNss8LdYtsiLejdOfXuG7GnnCrZ2Ew7IqDzKXCFmMjqkYkVqvYJZgvcgGum5U2khcvRB3f4DA22aOBofPycOSRPmSo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779732106; c=relaxed/simple; bh=uQDtGl1GZehCkeUJvy50GOF0qMnGqzE+lOEJiutJFMI=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=Bta2tjJ1B3ud/yHlb4BnqC2KRmrlhk9oRPmVfgLt3kYdZXzpw7/Nfz1uK197BybO7tayVUHwihT2EgSefCiAjwGgQ6uoSTAh28xVGI+Hr/rTR06F96mTsDWG5KiAs38j6MkGYjjkp/gEoBl/uuTsnU9hw9CZGCZPsQtOGyeuVAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=E5UBQEQA; arc=none smtp.client-ip=74.125.82.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="E5UBQEQA" Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-1329fc4bf77so7608125c88.1 for ; Mon, 25 May 2026 11:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1779732104; x=1780336904; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fzor4pOAcoXrq0r/dQWN3ieh5O1PmvSJQr5rj+ToVL8=; b=E5UBQEQAnOUrlMiUQguDe1X4CPzHyqtORL9Him/enfTHhgntKUJq8sb++nZzg5UVH8 Cs6koqmuY+OjrtnYp5zwe5qPrGNPJX6OHnGK/ovag6PakFRACMjqo8mqAhmXbxJCGE8p 9cGsPqMxKL5NApvUdNIV1jd92SLxwOpCz/W32Wc4iy6ncJL2JZQTe+D9m7boXFV/GABY 7+Q0sR28LVPOmFt2TxxPQnUFeWJ1oyhOmKi92Z3joVWWmrXp256ZGgaNsUPixq3gVnmT mUxC8KU93bv3Tz2H3/7gM5rt4tTpbkBDbChuqf+bB4R0ZKqJofgD473Z8m5tvID/Las6 2FqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779732104; x=1780336904; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fzor4pOAcoXrq0r/dQWN3ieh5O1PmvSJQr5rj+ToVL8=; b=EJ11GrhMRYrqQ9+DqayjLAB1z5upjZUCTp46VTLdzmOiUM9V++dcbZnozM85dKplk3 OPxYByMejJ6OWVYqRPafZxPKD57Q2zTFDUAaXUyNCm1JcynUtCehNG8TWCJoY+h9z2kX PuKe+nPI4Q4IEhTJgEn4IpGpgeQKskyFeDyb/i1EK4bPZhNJWhf2CJuza84cbARMnvc0 1WJTpvqSAVJ7AgROlz9dJGU9x/dxohP32VOfbXs1bMBrnRBRDaucNZM4t7GdtyT+vDRt VPRS5q+nYVgpMqdUWQbP3q5Fbent4Jv3JlQDfIymvn3MOrHhsAtZrleOAoidDR526Wwm 6/8g== X-Forwarded-Encrypted: i=1; AFNElJ9/ReJhHg3+usUWtwaCURSN9KW0AP+NqHVWRnY6Pfv9weOK9ePAQmdEGCZfN41w2woOQFQXGHs=@vger.kernel.org X-Gm-Message-State: AOJu0YyMvUMhE2DRE8Z4Nk72mcWo6OqrfHMO8KsDVoN6fvHR1x1QKo4z Np9Py1JA2wxikWIt4iF3FKu22C5hpe7CYOyqErY53XSBkHrxekWEqzBaUcsO/MKfMEY= X-Gm-Gg: Acq92OE0xu04ciLOancD6hjnJmqIfd60tShiKGmUFD5l4BZVUgTrTtGxrmRXHwklkWi cd1C4qynLhhyRQp+RYYnIXrOkFwKiYZpIv8hPO7O30YvDNon4HdLyNZzN21RIwLjNmeEvHHUTIk gnmXrLOf2twp3vjhynR3WeFSlPJspCCY/1ZALskLJwK5MJRZonfw+HJN4ym0JZEpvDYjQPldoRz DkIqCn3/mwftXK7qawTEqrqTQYTRyZK6mTyk4oADww8YCWhqxXPc4UEFFbmUl6X8gj9ewk2jjka bKEBWm7FDvsVjhdlMGJgt2twCIQnxPBeiPQyIC+HR/aB+kvvdWNTphe+VfJrEcJZtg6km3d881u /fwfoi8baesXeSxGvzWnPvC+htIeJmorpV5H6UpLrw1IFafWivOqxCMGEHyD0pFY5q1glItY+wP TGk7w= X-Received: by 2002:a05:7022:ef01:b0:12c:8f92:c6ba with SMTP id a92af1059eb24-1365fc7b48cmr5378838c88.34.1779732103455; Mon, 25 May 2026 11:01:43 -0700 (PDT) Received: from localhost ([2620:10d:c090:600::cc2]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1366a2e634csm7642048c88.2.2026.05.25.11.01.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 May 2026 11:01:43 -0700 (PDT) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 25 May 2026 14:01:33 -0400 Message-Id: Subject: Re: [PATCH RFC bpf-next 3/8] bpf: add BPF_JIT_KASAN for KASAN instrumentation of JITed programs From: "Emil Tsalapatis" To: =?utf-8?q?Alexis_Lothor=C3=A9?= , "Emil Tsalapatis" , "Alexei Starovoitov" Cc: "Andrey Konovalov" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "John Fastabend" , "David S. Miller" , "David Ahern" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "X86 ML" , "H. Peter Anvin" , "Shuah Khan" , "Maxime Coquelin" , "Alexandre Torgue" , "Andrey Ryabinin" , "Alexander Potapenko" , "Dmitry Vyukov" , "Vincenzo Frascino" , "Andrew Morton" , , "Bastien Curutchet" , "Thomas Petazzoni" , "Xu Kuohai" , "bpf" , "LKML" , "Network Development" , "open list:KERNEL SELFTEST FRAMEWORK" , , "linux-arm-kernel" , "kasan-dev" , "linux-mm" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260413-kasan-v1-0-1a5831230821@bootlin.com> <20260413-kasan-v1-3-1a5831230821@bootlin.com> In-Reply-To: On Mon May 25, 2026 at 5:05 AM EDT, Alexis Lothor=C3=A9 wrote: > On Fri May 22, 2026 at 7:13 PM CEST, Emil Tsalapatis wrote: >> On Fri May 22, 2026 at 10:14 AM EDT, Alexis Lothor=C3=A9 wrote: >>> On Tue Apr 14, 2026 at 4:38 PM CEST, Alexei Starovoitov wrote: >>>> On Tue, Apr 14, 2026 at 6:24=E2=80=AFAM Alexis Lothor=C3=A9 >>>> wrote: >>>>> >>>>> On Tue Apr 14, 2026 at 12:20 AM CEST, Andrey Konovalov wrote: >>>>> > On Mon, Apr 13, 2026 at 8:29=E2=80=AFPM Alexis Lothor=C3=A9 (eBPF F= oundation) >>>>> > wrote: >>> >>> [...] >>> >>>>> >> +config BPF_JIT_KASAN >>>>> >> + bool >>>>> >> + depends on HAVE_EBPF_JIT_KASAN >>>>> >> + default y if BPF_JIT && KASAN_GENERIC >>>>> > >>>>> > Should this be "depends on KASAN && KASAN_GENERIC"? >>>>> >>>>> Meaning, making it an explicit user-selectable option ? >>>>> >>>>> If so, the current design choice is voluntary and based on the feedba= ck >>>>> received on the original RFC, where I have been suggested to >>>>> automatically enable the KASAN instrumentation in BPF programs if KAS= AN >>>>> support is enabled in the kernel ([1]). But if a user-selectable togg= le >>>>> is eventually a better solution, I'm fine with changing it. >>>> >>>> Let's not add more config knobs. >>>> Even this patch looks redundant. >>>> Inside JIT do instrumentation when KASAN_GENERIC is set. >>> >>> (with quite some delay) I think it would be better to keep this new >>> BPF_JIT_KASAN, because aside from the possibility to use it in >>> bpf_jit_comp.c, it allows to update tests affected by KASAN >>> instrumentation in a nicer way. For example, the test_loader subtests >>> that monitor JITted instructions are confused by KASAN. I can either >>> skip them or make them smarter when KASAN is enabled for BPF, but in >>> both cases, it would be nicer to just adapt the behavior based on a >>> generic CONFIG_BPF_JIT_KASAN, rather than sprinkling some "if >>> jit_enabled AND CONFIG_KASAN_GENERIC AND ARCH_X86" in selftests. That >>> still does not make it a config knob, that just creates an internal >>> Kconfig option that is automatically turned on when KASAN and JIT are >>> enabled at build time. >> >> Having a togglable config knob gives us the option to set up KASAN for >> the kernel but not for BPF, and I don't see why we'd want that. Imo we a= re >> already paying the cost of KASAN for the rest of the kernel, there is no >> incentive to not run it for the BPF JIT. Having to eat the complexity co= st >> in the selftests seems reasonable if the alternative means a cleaner >> interface for the user (preventing them from choosing an unreasonable >> combination of options). > > Again, this does not expose a togglable knob, this is a purely internal > kconfig, automatically enabled if CONFIG_KASAN_GENERIC is set and if the > architecture-specific Kconfig defines HAVE_EBPF_JIT_KASAN (since we want > it for x86 only), and there would be no way to enable KASAN for kernel > only and not for BPF, or the other way around. What I am proposing is > just an internal, architecture-agnostice kconfig to avoid conditioning > some selftests to any architecture.=20 Makes sense, in this case this seems reasonable. > > Alexis