Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2927560rwb; Mon, 15 Aug 2022 14:13:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nnRAsqqK+hhUYnGv8C94wSrhOhBXPk+P9rbSZ5wkgpWMMlfpQ5pXv/1GNQv5+lCDMW8ZD X-Received: by 2002:a05:6a00:1950:b0:534:e7e4:804 with SMTP id s16-20020a056a00195000b00534e7e40804mr5892923pfk.17.1660597981666; Mon, 15 Aug 2022 14:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597981; cv=none; d=google.com; s=arc-20160816; b=LEiWr9Rm3vdP1QQmnAJmbyTQiyrzXARU6I9QKr/rO21VI2htcHooflIpD+jxqV/aMh XrZ9YYMnEcq4wxDNd5+GS8jKwIql8PdE/e4MDHZNusAzf7bGtz7bLgMKyLh8DXbLPXHU qGvm6OGU0bZq5CLGbHNNhXsptvgmmmCSWhO5IwK+0ejGBuOOne2msEzd0sWsV46LPxEP I46w4OHh5+gRhANtTNBDbMDEILn4TyPwbBfjMEQhoUMsJxqEAMgAMYEISrBFDOp2MOhB jNi9ZutJ3yeKjCCITCTy4TbQXDRDfMIgtFG/EVRkkbQcNwyDEuxgDexWIO+FvbUk/WCR d06w== 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=ONmlRH6HW/tcC8CeGYXQkM4JGNGfXzTSpRWahAQW6GU=; b=WlTpn/h4smsjkvymLRYa6QRW7ogdFnj+kdpRA5V4taLrU3E0vxcw97c/MRywzRtQUg hvXq46AKu9Efb26h1iJmzBvVa9Mk9aADx+yfk3Xsx9llkuzPGFnttNPe3u5SOd7oWE6g GgV2Kdxfa0fKyCLrMILqcyqXVEhf8RZMmmnYO0Y1S3Pfz1eBakMJaOgGvy3pD5zLp1Zc ORrx7AHxE5H3OeTzkNohfBs2/HYhIUkIYMRRbnFwyHIpLWjhGEAT2JZHQv3Xy2Bo5GWM PFIGt7odQwjmw73xSrZGM4s5W3IXKUNla1dj8moIU9PJyp5tPwIshG9WZDHxIgcneVj0 mpZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GaYjfbml; 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 bd32-20020a056a0027a000b0052f9dd05116si1508142pfb.171.2022.08.15.14.12.50; Mon, 15 Aug 2022 14:13:01 -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=GaYjfbml; 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 S1346696AbiHOUxi (ORCPT + 99 others); Mon, 15 Aug 2022 16:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347327AbiHOUvw (ORCPT ); Mon, 15 Aug 2022 16:51:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CBCE5F9C; Mon, 15 Aug 2022 12:10:24 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 14B1D60BBF; Mon, 15 Aug 2022 19:10:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02F91C433D6; Mon, 15 Aug 2022 19:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590614; bh=6xO0dtf62kZWzM4FlVGVCYWpoIe5YdSyyqKESUm66QE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GaYjfbmlaWs3zLHFqg5sNELk1/+CK9qEKX6TUK22cs42GODVy3dJCTDUlWki5zo5J 4jYL/H5J/z3ry639+5j2CL8uWtO6TadddxV3t4gvINlEFyXG407GCiZ9sfp1yfBaFE n3+t3cNt1zhi/6pOXbtZ3XDRV4BdxVjRpRY9Y8Ik= 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.18 0315/1095] selftests/bpf: Fix test_run logic in fexit_stress.c Date: Mon, 15 Aug 2022 19:55:14 +0200 Message-Id: <20220815180442.825390550@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 3ee2107bbf7a..58b03d1a70c8 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 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 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 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