From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej2-f10.google.com (mail-ej2-f10.google.com [74.125.228.138]) (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 C5D292D1931 for ; Sun, 23 Aug 2026 22:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787524812; cv=none; b=t/tCx9+ubzS7GYfT1W2r7JuFxoWepl8iM/8a4SFO11xT0gH1F2SQ7bGNN4jt0MzE4bxvUrOEr70JzMR+B5mFt/hEJ0q7r4Xdm+IE3zTS4oSS+1RdFabBM6atEzgpPnztF248vnAnohn/7NyRIXjnC0wMfec7vb0qvXN1Vx7oOxY= 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.138 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-ej2-f10.google.com with SMTP id a640c23a62f3a-c1fd40c88b6so184630866b.0 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=G6Bh+13F5X7ksNt4Hr9X7eMnkzGDZSrNaLCPCmZ+7GwevF4VRguLlfls8YY0uZ6FYP sOEPjK0aTjVAwBLN3jvBHOcqMXwryAa39ExHodahw+19+bL15IPvM2oc286AyeCQYrhG bcCEGkuD/xJ1pU4jwiVmjL94M1AEI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:b0: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-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: 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.