From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed2-f8.google.com (mail-ed2-f8.google.com [74.125.228.72]) (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 C3ADD1A682E for ; Sun, 23 Aug 2026 22:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787524812; cv=none; b=X7kuQNoi0Ko+G4y40Iq/lvwCDrTu/NfO08fBHk4467aqfelui5lu/rLb8t5lndxKCq4EzadFKafvMW8LerpzSXA/p8oTglyTzy9PVGScPsGFK0DjKI92ge7CH7cenhe21f1BLy1IMtboKXAzXw+gua8wVjMITJvxlaxATPO/M5U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787524812; c=relaxed/simple; bh=pEz9ZSO+xs/hhGJgo+ZI91I+V5+Shv/JSkecAPzFNmA=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=fFto0idR4ZJNGc3VNBo1kv6OHRfrJhaVTF7mLNR0jGlQixC3SEcW2hRScSAm8V+ssw8AvWblx4vJOWzyYK6foED8fWPa8jt3amMTfhU15eOXsHzzILCfwCYz6NVi6wwPHsfJ0mzle4uuEoskKeQrUI3pZ3EWj6rRDrtM8tzTuXw= 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=f0LhtUuE; arc=none smtp.client-ip=74.125.228.72 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="f0LhtUuE" Received: by mail-ed2-f8.google.com with SMTP id 4fb4d7f45d1cf-6a18ef2253bso2111228a12.1 for ; Sun, 23 Aug 2026 15:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787524809; x=1788129609; 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=SG9rgDtNieYPykAvrJ3FehcRXBgEFFy+2SYvBOFnmm4=; b=f0LhtUuEMwoLIHDJ4NnvfUMQXyfAQAcZ3VCrJPC5nD0cdC/lv8sZMoK9uXcih5RTNw usOe7d7T2vkZZ/Yp2USXJ2eQCYObalWTTHIzG95za/0VJ3oRvBuuooTUUYD4Vhbs/O1V nUeafnmbqQoeZyGANlWkIvCgPlvg4UsVi+SboqPTbFIw9Bex+itI2Kizyym2InEjsAq/ I+dTKwEM5QXjG2fxVyNVA5z+yadinql/QBnoD2zEwg42nnn4GCOvmgHyTPwpOcVkdUuN T0Zaa0yJjGyxg1NpCU+2A+ZavoQ4viUR+8A7OJ3+sA36BLfI+sJBGPBPpAEbltB5K4ot 5ptA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787524809; x=1788129609; 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=SG9rgDtNieYPykAvrJ3FehcRXBgEFFy+2SYvBOFnmm4=; b=ahCjbYdhiaTsPMISeMqwSnMQodG8WdDuH2HqsQb6gjJ1RfUDe4krdOVj83JdJvLc18 UyrLY1gdGY/NUqG3u9aimrR1EK01Fq5MWWxXyBgMjkA4jfEroQvMsaCn73FVFeFmcGN5 yRsUxsjsbKFcK1uCBvaEjON6IvIidzRMgK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0:c20:56e8:5457 with SMTP id a640c23a62f3a-c246a359c6fmr2106818166b.6.1787524808751; Sun, 23 Aug 2026 15:40:08 -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-c249606b4f1sm869047766b.3.2026.08.23.15.40.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Aug 2026 15:40:08 -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: Mon, 24 Aug 2026 00:40:07 +0200 Message-Id: Cc: , "Bastien Curutchet" , "Thomas Petazzoni" , , , Subject: Re: [PATCH bpf-next v7 9/9] selftests/bpf: add tests to validate KASAN on JIT 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: <20260822-kasan-v7-0-99afee6ef7fd@bootlin.com> <20260822-kasan-v7-9-99afee6ef7fd@bootlin.com> In-Reply-To: <20260822-kasan-v7-9-99afee6ef7fd@bootlin.com> On Sat Aug 22, 2026 at 12:39 AM CEST, Alexis Lothor=C3=A9 (eBPF Foundation)= wrote: > Add a basic KASAN test runner that loads and test-run programs that can > trigger memory management bugs. The test captures kernel logs and ensure > that the expected KASAN splat is emitted by searching for the > corresponding first lines in the report, hence validated that the needed > instrumentation has been inserted by the JIT compiler before the > relevant memory accesses. To allow each test to trigger the expected > report, the kernel must run with the kasan_multi_shot configuration. > > The runner covers different cases and settings: in the nominal case, it > validates kasan reports on basic instructions (on all supported accesses > sizes) but also when report _should not_ be emitted (eg: for accesses on > program stack). The runner also comes with a few specialized tests that > are then not executed for all sizes/locations: > - specific atomic ops > - test for instructions involving different verifier states, with some > states flagging memory as stack, and other states as non-stack memory > - tests that validate the stack marking shifting when a patch is emitted > by the verifier (zext/rnd_hi32, constant blindind). > Most of those tests are able to trigger kasan reports by altering the > shadow memory (triggering faulty accesses is otherwise complex, because > of the verifier). A few tests trigger actual faulty accesses (eg > out-of-bound accesses) > > A few of those tests depends on cpuv4 (load_acquire and store_release). > > # ./test_progs -a kasan > #171/1 kasan/st_1_not_on_stack:OK > #171/2 kasan/st_1_on_stack:OK > #171/3 kasan/st_2_not_on_stack:OK > #171/4 kasan/st_2_on_stack:OK > #171/5 kasan/st_4_not_on_stack:OK > #171/6 kasan/st_4_on_stack:OK > #171/7 kasan/st_8_not_on_stack:OK > #171/8 kasan/st_8_on_stack:OK > #171/9 kasan/stx_1_not_on_stack:OK > #171/10 kasan/stx_1_on_stack:OK > #171/11 kasan/stx_2_not_on_stack:OK > #171/12 kasan/stx_2_on_stack:OK > #171/13 kasan/stx_4_not_on_stack:OK > #171/14 kasan/stx_4_on_stack:OK > #171/15 kasan/stx_8_not_on_stack:OK > #171/16 kasan/stx_8_on_stack:OK > #171/17 kasan/ldx_1_not_on_stack:OK > #171/18 kasan/ldx_1_on_stack:OK > #171/19 kasan/ldx_2_not_on_stack:OK > #171/20 kasan/ldx_2_on_stack:OK > #171/21 kasan/ldx_4_not_on_stack:OK > #171/22 kasan/ldx_4_on_stack:OK > #171/23 kasan/ldx_8_not_on_stack:OK > #171/24 kasan/ldx_8_on_stack:OK > #171/25 kasan/simple_atomic_4_not_on_stack:OK > #171/26 kasan/simple_atomic_4_on_stack:OK > #171/27 kasan/simple_atomic_8_not_on_stack:OK > #171/28 kasan/simple_atomic_8_on_stack:OK > #171/29 kasan/simple_atomic_fetch:OK > #171/30 kasan/simple_atomic_fetch:OK > #171/31 kasan/load_acquire_1_not_on_stack:SKIP > #171/32 kasan/load_acquire_1_on_stack:SKIP > #171/33 kasan/load_acquire_2_not_on_stack:SKIP > #171/34 kasan/load_acquire_2_on_stack:SKIP > #171/35 kasan/load_acquire_4_not_on_stack:SKIP > #171/36 kasan/load_acquire_4_on_stack:SKIP > #171/37 kasan/load_acquire_8_not_on_stack:SKIP > #171/38 kasan/load_acquire_8_on_stack:SKIP > #171/39 kasan/store_release_1_not_on_stack:SKIP > #171/40 kasan/store_release_1_on_stack:SKIP > #171/41 kasan/store_release_2_not_on_stack:SKIP > #171/42 kasan/store_release_2_on_stack:SKIP > #171/43 kasan/store_release_4_not_on_stack:SKIP > #171/44 kasan/store_release_4_on_stack:SKIP > #171/45 kasan/store_release_8_not_on_stack:SKIP > #171/46 kasan/store_release_8_on_stack:SKIP > #171/47 kasan/ldx_patched:OK > #171/48 kasan/ldx_patched:OK > #171/49 kasan/verifier_paths_stack_and_non_stack:OK > #171/50 kasan/ldx_oob_1_not_on_stack:OK > #171/51 kasan/ldx_oob_2_not_on_stack:OK > #171/52 kasan/ldx_oob_4_not_on_stack:OK > #171/53 kasan/ldx_oob_8_not_on_stack:OK > #171/54 kasan/st_blinded:OK > #171 kasan:OK (SKIP: 16/54) > Summary: 1/38 PASSED, 16 SKIPPED, 0 FAILED > > Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) > --- 1. Should this test be made serial to make sure bpf_jit_harden sysctl chang= e doesn't affect other tests? 2. Clang currently collapses the intended ST/STX distinction for *_on_stack tests: default/v3 emits STX for both pairs, cpuv4 emits ST for both, and th= e default st_blinded object is already STX and therefore is not blinded. Plea= se check and assert that xlated insns are correct in the test itself if possib= le. It might be necessary to use asm volatile assembly blocks in case you canno= t work around the compiler in C.