From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 3C408372675 for ; Fri, 22 May 2026 17:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470022; cv=none; b=N4jcHEjHmPeQYYZrGIIvuR8R5ZWFlv3SKssZoQMEesw4Chkf3Mcq72XSyRCjoJg7Kp6yEfpb1GEyP5T712g8wgZAFhSc/i0Vax0p7rowWZuq80gsZpGCElHo0zb5bHgkl5VBnOELRTZQJaQxl9iT3taEUqzqkrMUqjJWnt6VaMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470022; c=relaxed/simple; bh=a+CInxeSB1Zqe7+X7tbNilMFXAdB47JkuFSLHzgtQp0=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=Kd7YUuAdSc3qgRtOFrsg+RFI2LBpkPXaAK2Q5Y20FkGL3eVufk3NjX3Gt61/ztrpfcZXXjw0FL7Z6dNSttSVnynw10f29mf+v+EwUjhhYioS8CejtUWFQj6Olj7AkXSTP3Jaq3EE0NFE46yAiKd9m7CRbSu+/Z7q2AI55phus64= 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=mb5avOus; arc=none smtp.client-ip=74.125.82.174 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="mb5avOus" Received: by mail-dy1-f174.google.com with SMTP id 5a478bee46e88-3042dffd80bso3546649eec.0 for ; Fri, 22 May 2026 10:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1779470020; x=1780074820; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wY4I8lMoFI92sp/KvSm+KBFNyjnf2+5FqBSVyBYIdTY=; b=mb5avOusvH++FgQcBBfSDMOsB1NyLQKilnVtcHQxyJBsnXRzm8q4NnE7ilDv/f/pnL h7SgTyEQyWIQknSdq+vG2gLE0yQyhn5Hdk4du3LBRrVNfY5p4c095DyH2/28wqcdxVgj KABArBH7YfUiM7LF7AAroA/UIdMn5oSDk4+13FWGXmk0UdrpNQzkB6l4idqTrTh8YCIN 2i592+RByhRugCuxZ2YQuWOjRnKhZMPwKQwZFZm2mhXu2/4XITbQS7bEl9bi5oaNd+HL XOIKThbxeedA0VS0iGfhfz80NsrYsQ9xnAvCi0uBKHRCGPvAnsbXzZflULPXAKGgYrGM jb9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779470020; x=1780074820; h=in-reply-to:references:to:from:subject:cc: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=wY4I8lMoFI92sp/KvSm+KBFNyjnf2+5FqBSVyBYIdTY=; b=dM3SEAF1UhUHhBB92SglOcyGzF4CSl7p8VkqTJ57/ofvwl+OuLHvLC9Fk2AcBDe0mO bL0HfUEmwc/vEXJKDQmbZfktOPOp7Dqrkk+pJjuPZMzo9i41AvUOyrG5OAPfzpT8g476 TjnQlIgBxWvUqWZpsBwSCIv1hpINVS8VmZ6vTpdb9UNM2PmAZkYb6NjNEiDwXrhV4kfO XiLeqjeotyIYuTC3gm/5RtPJ6Bk6yN/4n1XdxJ640kbUwqhXd3hwiE5GYP2xp6TcSNYw mYdUs3zcJIZMpVd6BkVD+vOzqtDv/FNcgzNV1ddqo1M3vwisFBpVoKvdQ70YAxhWzBIN 2p9w== X-Forwarded-Encrypted: i=1; AFNElJ8w1mQcdtuDnNJCp9diQaF3MIuGAyPeISCqI8W3eZsubPoB11Toap2ZM+U9PejHC4gLirk40RgIEf34K2o=@vger.kernel.org X-Gm-Message-State: AOJu0YzCDYdBvo02HvH5t4SI9FWoVeYBNT9dDbfjZiL86/nGa9C3hbJx ZONwylNNBCHVJN3g7A3WTzW1xh2ZAfdPIfIkICVWi9jKBlH807+bUc6fGFO4jA0oaCs= X-Gm-Gg: Acq92OFHFiiPvrdfNRJYvDUl1z9jQKwTo8KRyP/EPTp4cEJFvQwzaR/NaCgUMPSy+IZ 8kh5B2NHvG9n/pVq/m4OKgmCQjk8e+kzY7YDIkc7MEmoZeVMsYDAr5sRFewovsssdRCZOrG31WQ 1vKdCK4RfjXghy1AQlynXWe0wduTK39X/V8kRmHD2YrjATFPqsLsTupct8Zo1BoamYpyjhe4vqh lqLiUeQ6LGUdsHqfBulDP1Pj09Xh3CC0UAXmoE/ijdTX8Yx4I0e5/deGuzkSRxYao97ZilYCYbf pE0t8csFAzefsqQzDl4VbU84r9+6Y4K7xPnHNEfe84B4DFTmKPKsarWsEMub2u3qf/k/kNCwVZi oxhdyYtnPxMsliXQuKPz6AB73JPerS+mQc+jQmqzVAsrevAsdW/rBWHaWQ172zOyt3E6XYlOKd/ Mu0oloVvk3s5OnQRo= X-Received: by 2002:a05:7301:168b:b0:2be:833c:149d with SMTP id 5a478bee46e88-304491e11fcmr2091389eec.28.1779470020197; Fri, 22 May 2026 10:13:40 -0700 (PDT) Received: from localhost ([2620:10d:c090:600::69da]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30451f3feadsm1872911eec.13.2026.05.22.10.13.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 May 2026 10:13:39 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@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: Fri, 22 May 2026 13:13:35 -0400 Message-Id: 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" 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?= , "Alexei Starovoitov" 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 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 Fou= ndation) >>> > 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 feedback >>> received on the original RFC, where I have been suggested to >>> automatically enable the KASAN instrumentation in BPF programs if KASAN >>> support is enabled in the kernel ([1]). But if a user-selectable toggle >>> 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 are 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 cost in the selftests seems reasonable if the alternative means a cleaner interface for the user (preventing them from choosing an unreasonable combination of options).