From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796462731; b=NNqkCSALRV2yXN9nfp4LLRs3efKzdiL129IM+LL/1u+qElrG++nABvxRwF8nEZhcwntH 7BWjPKK33/EGUGMU3H8VZ1xdNWvW4DqTZoEzNX6WC9FWrqJNyYXgJmY+soWPajzd9ekzh TNEVwjI97S16kfpd5rHkYmkPHzZxDmnaOOWtnCNS8b4V9eSEkGMBBfVEbVLDbSDHo5Yae ET1ldpIX1g3wAt9B4Kf9JG2XMDEZcc/hkB+eYMw3pwFrHP0mgl8h6ZWL2B8E3K0MaECRB HbIFmPQG/uldqDJ5K9tZslPaP6nb7N1VMOUtj9A76LX+1z8RaoaytYA8K4prtK07daw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796462731; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zz2P7FlWmo2tilwuM1BQcqZPq6a6modqoOaCBIA0nt8=; b=zqheCv842xQ2a3wF6tXItLCgqTwynu6Qdh6vPsJEKD70Ijps3e8VxXl77ImckC9A30p7 GlJLWPfc1o5AOdxnZch7zdLyNjWqtvXCnz7PDegs36h9PdRY1k/dfYoH3d8w2hJQKBt3m 67ZL/NTlpozWY7ZaNGkc7d0FMRfwwOyoMmPiLkb4veSKWbNwdgK3LbwdCwpz/oWpIH7BN 6fGbI5sVZ4tSMWBfU2pD1YMO5qVVyXTH65EIGneF6WAFIOVmirA2MhRP82LFf80xX1hQZ rfcO8sqtvkuvf8SDPwEEajuTisdGsj3En4BO6C1cSBc/AkTEBL/0btL1/zCW9IhWRig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WU+PN6xv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDC7D606A322 for ; Sat, 5 Dec 2026 09:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WU+PN6xv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 683961F0092B; Sat, 5 Dec 2026 09:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796462731; bh=zz2P7FlWmo2tilwuM1BQcqZPq6a6modqoOaCBIA0nt8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=WU+PN6xvoiSzMEqqlwiLzcp3Qtmo2Y8YOzjM0PPjXeDfB4ZQVTGEfpu3o81Syieud 0FowLRNKMuRt5MdiqRjaxLpq6Rsvdjy9b4X1AN+T41nzN6/zivhHmE5WYHJBu7/B1F 5Ovu+GGu84hYlo+QbhKFuB6m76xkH9UmHNTwFJqiQfOlyyDBkzOiOX3oBW9Nq+sS2x sZHpzNLXaNwCJCFFlVgYsjCQz+rVRxu9RnCFrBPy/kGSKlIenDSPvVRunqVomAEHD8 ZSh6ZlaF5czD/PASuK3mH/N5HNxd32yqQ0eFfcHJFCnqogG64nAMcoQbPjd6TxrvNH ndjexmJXDNWXg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf 2/2] selftests/bpf: Test raw_tp test_run ctx padding for tail calls Reply-To: sashiko-reviews@lists.linux.dev To: "Pragyansh Chaturvedi" , bpf@vger.kernel.org In-Reply-To: <20261205090934.3813585-2-r41k0u@ubuntu.com> References: <20261205090934.3813585-1-r41k0u@ubuntu.com> <20261205090934.3813585-2-r41k0u@ubuntu.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 09:25:31 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] selftests/bpf: unguarded clang unroll pragma in target() breaks bpf-gcc - [Medium] bpf: bpf_prog_test_run_raw_tp() pads tail-call ctx to U16_MAX instead of 96 - [Low] selftests/bpf: multi-line comments violate BPF comment style -- commit 8ee6e23e90a8d457fc8e1491da0ce6b2ea624028 Author: Pragyansh Chaturvedi selftests/bpf: Test raw_tp test_run ctx padding for tail calls This commit adds the tailcall_raw_tp_ctx subtest to prog_tests/tailcalls.c and a companion BPF program in progs/tailcall_raw_tp_ctx.c. The test runs a raw_tracepoint caller with an 8-byte ctx via BPF_PROG_TEST_RUN and checks that a tail-call target reading 96 bytes of ctx sees zeros past the first 8 bytes. > diff --git a/tools/testing/selftests/bpf/prog_tests/tailcalls.c b/tools/t= esting/selftests/bpf/prog_tests/tailcalls.c > index 88d223110ecd5..be3bb8584947e 100644 > --- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c > +++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c > @@ -17,6 +17,42 @@ > #include "tailcall_callback.skel.h" > #include "tailcall_bpf2bpf2.skel.h" > #include "tailcall_bpf2bpf_fexit.skel.h" > +#include "tailcall_raw_tp_ctx.skel.h" > + > +/* test_tailcall_raw_tp_ctx checks that a raw_tp program run through > + * BPF_PROG_TEST_RUN gets a zero-padded ctx when it can be reached by a > + * tail call. The caller supplies 8 bytes of ctx and tail-calls a > + * target that reads 96 bytes; without the padding the target reads > + * out of bounds and (almost surely) non-zero memory, failing the > + * retval check. > + */ [Severity: Low] This isn't a bug, but BPF code uses the modern kernel multi-line comment style where the opening /* sits on its own line, even when surrounding code uses the older style. Both this comment and the multi-line comment in target() in progs/tailcall_raw_tp_ctx.c put text on the opening /* line. [ ... ] > + /* raw_tp test_run does not accept repeat */ > + LIBBPF_OPTS(bpf_test_run_opts, topts, > + .ctx_in =3D ctx, > + .ctx_size_in =3D 8, > + ); > + err =3D bpf_prog_test_run_opts(bpf_program__fd(skel->progs.caller), &to= pts); [Severity: Medium] Should bpf_prog_test_run_raw_tp() pad the tail-call context to MAX_BPF_FUNC_ARGS * sizeof(u64) (96 bytes) instead of U16_MAX? In the preceding patch in this series, commit "bpf: Give a raw_tp test_run program the largest context when it does tail calls": net/bpf/test_run.c:bpf_prog_test_run_raw_tp() { ... /* the target of a tail call can use that much */ if (prog->aux->tail_call_reachable) size =3D max_t(u32, size, U16_MAX); ... } raw_tp programs can only tail-call other raw_tp programs, and bpf_tracing_ctx_access() caps their context access at sizeof(__u64) * MAX_BPF_FUNC_ARGS (96 bytes), matching the ctx_size_in limit already enforced in bpf_prog_test_run_raw_tp(). Padding to U16_MAX makes every raw_tp test_run of a tail-calling program allocate and zero 65,535 bytes via kvzalloc() (requiring order-4 pages or a vmalloc fallback) instead of a 96-byte slab allocation. [ ... ] > diff --git a/tools/testing/selftests/bpf/progs/tailcall_raw_tp_ctx.c b/to= ols/testing/selftests/bpf/progs/tailcall_raw_tp_ctx.c > new file mode 100644 > index 0000000000000..e8380d19892a7 > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/tailcall_raw_tp_ctx.c [ ... ] > +SEC("raw_tracepoint/sched_switch") > +int target(void *ctx) > +{ > + __u64 *a =3D ctx; > + > + /* The test runs the caller with an 8-byte ctx. Everything past > + * the first u64 must read as zero: without the test_run ctx > + * padding, these reads are out of bounds and leak whatever > + * memory follows the small copy. > + */ > +#pragma clang loop unroll(full) > + for (int i =3D 1; i < 12; i++) { > + if (a[i]) > + return 1; > + } [Severity: Medium] Does this unguarded #pragma clang loop unroll(full) break the test_progs-bpf_gcc build? BPF_CFLAGS enables -Wall -Werror and the bpf-gcc build does not pass -Wno-unknown-pragmas, so bpf-gcc fails with -Werror=3Dunknown-pragmas (and without -Werror would not be instructed to unroll the loop). Including bpf_compiler.h and using __pragma_loop_unroll_full handles both Clang and bpf-gcc. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205090934.3813= 585-1-r41k0u@ubuntu.com?part=3D2