From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed2-f11.google.com (mail-ed2-f11.google.com [74.125.228.75]) (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 3002C431A22 for ; Fri, 4 Sep 2026 09:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.75 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788512559; cv=none; b=Ax0Oow6HXrvW+on5IL5ZuQzCkc7INgWF5LhKpkiYarYBn364QrTjNIUfTjUzm1vVaGPwCU900Emxj7LIprQVMcS8u8FKDw3/bVXI734WiLp1xZgJypwuj3xEanu2K9QzfzNKE/cuDk6lM4reX9HRtMtzGcQ54k5kdb8mzGWIWPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788512559; c=relaxed/simple; bh=FocYj1Tg6JeoZyTDyfHblEWp+ZMU7BmLVvhrp05G4mE=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=gZrdpLXX/5vJ/vNmuk8ken2DdJQLDhEiyCoU+cq2oYx9mcQ7qclvV+V01vY0Qk/QgQrndtRMyYFmfqMb6PJblvGfWfHmQZ8AqPStysUSB+gD4Mv1dPPAVXRUQQfiWL0kez0stvNOvZ0ZXuNjPmq/2UR3EGQ8bafAqJ1wWtC1qsE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ahLmHHkU; arc=none smtp.client-ip=74.125.228.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ahLmHHkU" Received: by mail-ed2-f11.google.com with SMTP id 4fb4d7f45d1cf-6a144c8f038so351459a12.0 for ; Fri, 04 Sep 2026 02:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788512556; x=1789117356; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=VSBcA76yWuklBIVlW8nFJkprKtYg80K7J6L7TsEg75w=; b=ahLmHHkUUY5GyLFEnMgSOAo6lncxD0syIQsq9xaGV+PMU31VF/R0AWp1T1/XGVjJ7m HyWJ6ezyl+fjWFsxwts/r4gMnEFYYrohLFL5iEBQs0Ti1XSxFN+F8sASHgWbPzuuUwBw liwG7psGLFP2IfFG7ov6CWJztbtotCJ7nUQDDS7u54xWuXRJjljy+C3dSPaOZDET/eyh HxP26qOtsXoJVsZ3a7Q6u2BZqigbdT7cq82dDmGsB2NfrnjNUpYaKE1jtCldZD4m9KSc y6PHgMqjCn5Qi0tG5orQ4q1fLkSmUKySZBUVCNIz1CfwAeb5G+VvDVjMSghbqXxAgCVZ a8mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788512556; x=1789117356; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VSBcA76yWuklBIVlW8nFJkprKtYg80K7J6L7TsEg75w=; b=XoaOqBEe6SSRIJJJX5O0WY0KOGy0Pnp2bu9DYUdZVeldDDdo6hjZaRBdZRuoi5I5d8 sOM2C0qRdSqAhkReFIhL7LzJNqWt0Ynaib9Teaqx+dYDnkst57ILY8G8mrOLETgrNSMC 7/yAXQF+PG9xwv/lLbyGJSdpfHg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002:a17:907:c81a:b0:c25:659:89ba with SMTP id a640c23a62f3a-c260c8d4e21mr198032866b.9.1788512555920; Fri, 04 Sep 2026 02:02:35 -0700 (PDT) Received: from localhost (nat-icclus-192-26-29-3.epfl.ch. [192.26.29.3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c260d503f96sm77028066b.26.2026.09.04.02.02.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Sep 2026 02:02:35 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kselftest@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, 04 Sep 2026 11:02:34 +0200 Message-Id: Cc: , "Bastien Curutchet" , "Thomas Petazzoni" , , , Subject: Re: [PATCH bpf-next v9 0/8] bpf: add support for KASAN checks in JITed programs From: "Kumar Kartikeya Dwivedi" To: =?utf-8?b?QWxleGlzIExvdGhvcsOpIChlQlBGIEZvdW5kYXRpb24p?= , "Alexei Starovoitov" , "Daniel Borkmann" , "John Fastabend" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Thomas Gleixner" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , "Shuah Khan" , "Ingo Molnar" , "Andrey Konovalov" , "Emil Tsalapatis" , "Ihor Solodrai" , "Yafang Shao" X-Mailer: aerc 0.21.0 References: <20260903-kasan-v9-0-2407fe99255a@bootlin.com> In-Reply-To: <20260903-kasan-v9-0-2407fe99255a@bootlin.com> On Thu Sep 3, 2026 at 3:51 PM CEST, Alexis Lothor=C3=A9 (eBPF Foundation) w= rote: > Hello, > this is v9 of the series aiming to bring basic support for KASAN checks > to BPF JITed programs. Among a few minor optimizations, this revision > fixes some wrong kasan instrumentation on some unwanted stack access > (stack access ending up being instrumented AND targeting the wrong stack > offset). To mitigate this risk further, this revision introduces a > systematic KASAN check skip when (addr_reg =3D=3D BPF_REG_FP || addr_reg = =3D=3D > BPF_REG_PARAMS) in emit_kasan_check. This secondary check (on top of the > non_stack_access flag), should hopefully prevent the issues raised in > v8. I've also reworked the emit_st refactoring to realign it with > BPF_STX management in the x86 JIT compiler, as the "arguments on stack" > feature made me realize that it could be kept more symmetric with > BPF_STX; so I've dropped Ihor's Acked-by on this. > > Original cover letter: > > "Traditional" KASAN allows to spot memory management mistakes by > reserving a fraction of memory as "shadow memory" that will map to the > rest of the memory and allow its monitoring. Each memory-accessing > instruction is then instrumented at build time to call some ASAN check > function, that will analyze the corresponding bits in shadow memory, and > if it detects the access as invalid, trigger a detailed report. The goal > of this series is to replicate this mechanism for BPF programs when they > are being JITed into native instructions: that's then the JIT compiler > that is in charge of inserting calls to the corresponding kasan checks, > when a program is being loaded into the kernel. This task involves: > - identifying at program load time the instructions performing memory > accesses > - identifying those accesses properties (size ? read or write ?) to > define the relevant kasan check function to call > - just before the identified instructions: > - perform the basic context saving (ie: saving registers) > - inserting a call to the relevant kasan check function > - restore context > - whenever the instrumented program executes, if it performs an invalid > access, it triggers a kasan report identical to those instrumented on > kernel side at build time. > > The series comes with new selftests programs that generate a wide > variety of kasan reports: those need the kernel to be running with > kasan_multi_shot enabled. > > As discussed in [1], this series is based on some choices and > assumptions: > - it focuses on x86_64 for now, and so only on KASAN_GENERIC > - not all memory accessing BPF instructions are being instrumented: > - it discards instructions accessing BPF program stack (already > monitored by page guards) > - it discards possibly faulting instructions, like BPF_PROBE_MEM or > BPF_PROBE_ATOMIC insns > For the series: Acked-by: Kumar Kartikeya Dwivedi If there are remaining issues, we can fix forward, but I think we should tr= y and land this for now. > [...]