From nobody Mon Sep 29 21:12:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1304C25B0D for ; Mon, 15 Aug 2022 23:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243170AbiHOXW7 (ORCPT ); Mon, 15 Aug 2022 19:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353572AbiHOXQ5 (ORCPT ); Mon, 15 Aug 2022 19:16:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADB91AF4B1; Mon, 15 Aug 2022 13:03:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 97AFDCE12C5; Mon, 15 Aug 2022 20:03:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0438C433D7; Mon, 15 Aug 2022 20:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593811; bh=qq7+pJe4rKRzRhSQf0Bsb/dnSgaget5NFQmiFOvGCz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=McAmvE1AyJhsmWOs2SuRuhKkkow2imlf3CAwaUq8YuQ4S+I3PZAGA+ulSiIXF7/CK 67FOrH2cW6miWckvM1o8CPs9jf5OLq5Ex304S9lzAeIMGFuOylNJAtYmmbWXuu/6NW Q8JQHMGgRG64Id1aPzLPAlQm/NeI4zNsXyy4gksw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yuntao Wang , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.19 0329/1157] selftests/bpf: Fix test_run logic in fexit_stress.c Date: Mon, 15 Aug 2022 19:54:45 +0200 Message-Id: <20220815180452.817772660@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Yuntao Wang [ Upstream commit eb7b36ce47f830a01ad9405e673b563cc3638d5d ] In the commit da00d2f117a0 ("bpf: Add test ops for BPF_PROG_TYPE_TRACING"), the bpf_fentry_test1 function was moved into bpf_prog_test_run_tracing(), which is the test_run function of the tracing BPF programs. Thus calling 'bpf_prog_test_run_opts(filter_fd, &topts)' will not trigger bpf_fentry_test1 function as filter_fd is a sk_filter BPF program. Fix it by replacing filter_fd with fexit_fd in the bpf_prog_test_run_opts() function. Fixes: da00d2f117a0 ("bpf: Add test ops for BPF_PROG_TYPE_TRACING") Signed-off-by: Yuntao Wang Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220521151329.648013-1-ytcoode@gmail.com Signed-off-by: Sasha Levin --- .../selftests/bpf/prog_tests/fexit_stress.c | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c b/tools/= testing/selftests/bpf/prog_tests/fexit_stress.c index a7e74297f15f..5a7e6011f6bf 100644 --- a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c +++ b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c @@ -7,11 +7,9 @@ =20 void serial_test_fexit_stress(void) { - char test_skb[128] =3D {}; int fexit_fd[CNT] =3D {}; int link_fd[CNT] =3D {}; - char error[4096]; - int err, i, filter_fd; + int err, i; =20 const struct bpf_insn trace_program[] =3D { BPF_MOV64_IMM(BPF_REG_0, 0), @@ -20,25 +18,9 @@ void serial_test_fexit_stress(void) =20 LIBBPF_OPTS(bpf_prog_load_opts, trace_opts, .expected_attach_type =3D BPF_TRACE_FEXIT, - .log_buf =3D error, - .log_size =3D sizeof(error), ); =20 - const struct bpf_insn skb_program[] =3D { - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - }; - - LIBBPF_OPTS(bpf_prog_load_opts, skb_opts, - .log_buf =3D error, - .log_size =3D sizeof(error), - ); - - LIBBPF_OPTS(bpf_test_run_opts, topts, - .data_in =3D test_skb, - .data_size_in =3D sizeof(test_skb), - .repeat =3D 1, - ); + LIBBPF_OPTS(bpf_test_run_opts, topts); =20 err =3D libbpf_find_vmlinux_btf_id("bpf_fentry_test1", trace_opts.expected_attach_type); @@ -58,15 +40,9 @@ void serial_test_fexit_stress(void) goto out; } =20 - filter_fd =3D bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, NULL, "GPL", - skb_program, sizeof(skb_program) / sizeof(struct bpf_insn), - &skb_opts); - if (!ASSERT_GE(filter_fd, 0, "test_program_loaded")) - goto out; + err =3D bpf_prog_test_run_opts(fexit_fd[0], &topts); + ASSERT_OK(err, "bpf_prog_test_run_opts"); =20 - err =3D bpf_prog_test_run_opts(filter_fd, &topts); - close(filter_fd); - CHECK_FAIL(err); out: for (i =3D 0; i < CNT; i++) { if (link_fd[i]) --=20 2.35.1