Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3115329rwb; Mon, 15 Aug 2022 18:29:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ZjKTY8RVbxyHxktWX08vZGvc3is3ERMD7aiOX7opfTdRSuUx/rRCLus+PWwtYSzkJD71o X-Received: by 2002:a63:4608:0:b0:41a:617f:e194 with SMTP id t8-20020a634608000000b0041a617fe194mr16508248pga.152.1660613363833; Mon, 15 Aug 2022 18:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613363; cv=none; d=google.com; s=arc-20160816; b=0z0BIgYab7T5FtoOpQ0pwGRvU4M4QSFhB/YqiI9Q/uhjUFXaxBu0eLglMxgBXWOEFZ 9TE/Wg6mUm7n1CXkj2SiAtQrr25Hccj1HhX16OZtjyWPo4uKdCSSGBqdKZutXn8UnyMC P3mmf2sGEjNGqKW9yoc2CpdEKpmlJFTrDaGoGoCWk7yhkB3KBY+NLinS2d3x2eu4xtSw hP5hF7M5mlhu+F3PPqbPzObZy9UOhXl0e2wpLBWw1cb86AM1J2yyW4TfUUW3SgM/YVBh xZrj0qS4eWZm821huHP7o6tW447PCdtSraeIKzD2L9qOCxShQEUVAO+Hi/HOGGr5McCh NqlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LjtirvCLH6jkT0oimCPgQArkp5rkcimPjy/nnpx77H4=; b=edak8NxN7xADBNgNGF/CLeTu1qSTWkAbBOnckQfu9kf6cLf+PnQQWdZHf2hMDD74qO 0MXpaao39h/Oh6gO0Uw3mGPF+dKyT/3yNWH9PnexA1AIXbCQJjWX+l+0hk475ZlgzAtk ei4HFd5oipjab4SfjsU9ykytdSwkvQNiWm/A8xgA8cfv6M2do5MgzNNO8AFCv2EpOIc8 Rp7a04hjIXS5qEd4MDzrZeFrR9G3tDFIKgzJeDsUgdtWLPgcnmtJj9+g8qdfqFcnFAPo fQ8BD+X1aTkPMdyn1+ckvpecFCe4AdZQJSLHvV/JIEtleaEgY0dLEIaLwqrCnXJE/bak Fumw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=McAmvE1A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d20-20020a170902729400b001713d5d096esi12528207pll.14.2022.08.15.18.29.13; Mon, 15 Aug 2022 18:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=McAmvE1A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243082AbiHOXW4 (ORCPT + 99 others); Mon, 15 Aug 2022 19:22:56 -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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 @@ void serial_test_fexit_stress(void) { - char test_skb[128] = {}; int fexit_fd[CNT] = {}; int link_fd[CNT] = {}; - char error[4096]; - int err, i, filter_fd; + int err, i; const struct bpf_insn trace_program[] = { BPF_MOV64_IMM(BPF_REG_0, 0), @@ -20,25 +18,9 @@ void serial_test_fexit_stress(void) LIBBPF_OPTS(bpf_prog_load_opts, trace_opts, .expected_attach_type = BPF_TRACE_FEXIT, - .log_buf = error, - .log_size = sizeof(error), ); - const struct bpf_insn skb_program[] = { - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - }; - - LIBBPF_OPTS(bpf_prog_load_opts, skb_opts, - .log_buf = error, - .log_size = sizeof(error), - ); - - LIBBPF_OPTS(bpf_test_run_opts, topts, - .data_in = test_skb, - .data_size_in = sizeof(test_skb), - .repeat = 1, - ); + LIBBPF_OPTS(bpf_test_run_opts, topts); err = 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; } - filter_fd = 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 = bpf_prog_test_run_opts(fexit_fd[0], &topts); + ASSERT_OK(err, "bpf_prog_test_run_opts"); - err = bpf_prog_test_run_opts(filter_fd, &topts); - close(filter_fd); - CHECK_FAIL(err); out: for (i = 0; i < CNT; i++) { if (link_fd[i]) -- 2.35.1