From nobody Tue Apr 14 21:26:33 2026 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 2EA46C19F2C for ; Mon, 1 Aug 2022 07:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbiHAH3n (ORCPT ); Mon, 1 Aug 2022 03:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiHAH3d (ORCPT ); Mon, 1 Aug 2022 03:29:33 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACFF2F67E; Mon, 1 Aug 2022 00:29:30 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VL2sBHM_1659338966; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0VL2sBHM_1659338966) by smtp.aliyun-inc.com; Mon, 01 Aug 2022 15:29:27 +0800 From: Tianchen Ding To: Greg Kroah-Hartman , Sasha Levin Cc: Lorenz Bauer , Alexei Starovoitov , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 5.10 1/3] bpf: Consolidate shared test timing code Date: Mon, 1 Aug 2022 15:29:14 +0800 Message-Id: <20220801072916.29586-2-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220801072916.29586-1-dtcccc@linux.alibaba.com> References: <20220801072916.29586-1-dtcccc@linux.alibaba.com> 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: Lorenz Bauer commit 607b9cc92bd7208338d714a22b8082fe83bcb177 upstream. Share the timing / signal interruption logic between different implementations of PROG_TEST_RUN. There is a change in behaviour as well. We check the loop exit condition before checking for pending signals. This resolves an edge case where a signal arrives during the last iteration. Instead of aborting with EINTR we return the successful result to user space. Signed-off-by: Lorenz Bauer Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20210303101816.36774-2-lmb@cloudflare.com [dtcccc: fix conflicts in bpf_test_run()] Signed-off-by: Tianchen Ding --- net/bpf/test_run.c | 140 +++++++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 62 deletions(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index eb684f31fd69..d2a4f04df1da 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -16,14 +16,78 @@ #define CREATE_TRACE_POINTS #include =20 +struct bpf_test_timer { + enum { NO_PREEMPT, NO_MIGRATE } mode; + u32 i; + u64 time_start, time_spent; +}; + +static void bpf_test_timer_enter(struct bpf_test_timer *t) + __acquires(rcu) +{ + rcu_read_lock(); + if (t->mode =3D=3D NO_PREEMPT) + preempt_disable(); + else + migrate_disable(); + + t->time_start =3D ktime_get_ns(); +} + +static void bpf_test_timer_leave(struct bpf_test_timer *t) + __releases(rcu) +{ + t->time_start =3D 0; + + if (t->mode =3D=3D NO_PREEMPT) + preempt_enable(); + else + migrate_enable(); + rcu_read_unlock(); +} + +static bool bpf_test_timer_continue(struct bpf_test_timer *t, u32 repeat, = int *err, u32 *duration) + __must_hold(rcu) +{ + t->i++; + if (t->i >=3D repeat) { + /* We're done. */ + t->time_spent +=3D ktime_get_ns() - t->time_start; + do_div(t->time_spent, t->i); + *duration =3D t->time_spent > U32_MAX ? U32_MAX : (u32)t->time_spent; + *err =3D 0; + goto reset; + } + + if (signal_pending(current)) { + /* During iteration: we've been cancelled, abort. */ + *err =3D -EINTR; + goto reset; + } + + if (need_resched()) { + /* During iteration: we need to reschedule between runs. */ + t->time_spent +=3D ktime_get_ns() - t->time_start; + bpf_test_timer_leave(t); + cond_resched(); + bpf_test_timer_enter(t); + } + + /* Do another round. */ + return true; + +reset: + t->i =3D 0; + return false; +} + static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *retval, u32 *time, bool xdp) { struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] =3D { NUL= L }; + struct bpf_test_timer t =3D { NO_MIGRATE }; enum bpf_cgroup_storage_type stype; - u64 time_start, time_spent =3D 0; - int ret =3D 0; - u32 i; + int ret; =20 for_each_cgroup_storage_type(stype) { storage[stype] =3D bpf_cgroup_storage_alloc(prog, stype); @@ -38,10 +102,8 @@ static int bpf_test_run(struct bpf_prog *prog, void *ct= x, u32 repeat, if (!repeat) repeat =3D 1; =20 - rcu_read_lock(); - migrate_disable(); - time_start =3D ktime_get_ns(); - for (i =3D 0; i < repeat; i++) { + bpf_test_timer_enter(&t); + do { ret =3D bpf_cgroup_storage_set(storage); if (ret) break; @@ -53,29 +115,8 @@ static int bpf_test_run(struct bpf_prog *prog, void *ct= x, u32 repeat, =20 bpf_cgroup_storage_unset(); =20 - if (signal_pending(current)) { - ret =3D -EINTR; - break; - } - - if (need_resched()) { - time_spent +=3D ktime_get_ns() - time_start; - migrate_enable(); - rcu_read_unlock(); - - cond_resched(); - - rcu_read_lock(); - migrate_disable(); - time_start =3D ktime_get_ns(); - } - } - time_spent +=3D ktime_get_ns() - time_start; - migrate_enable(); - rcu_read_unlock(); - - do_div(time_spent, repeat); - *time =3D time_spent > U32_MAX ? U32_MAX : (u32)time_spent; + } while (bpf_test_timer_continue(&t, repeat, &ret, time)); + bpf_test_timer_leave(&t); =20 for_each_cgroup_storage_type(stype) bpf_cgroup_storage_free(storage[stype]); @@ -688,18 +729,17 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog = *prog, const union bpf_attr *kattr, union bpf_attr __user *uattr) { + struct bpf_test_timer t =3D { NO_PREEMPT }; u32 size =3D kattr->test.data_size_in; struct bpf_flow_dissector ctx =3D {}; u32 repeat =3D kattr->test.repeat; struct bpf_flow_keys *user_ctx; struct bpf_flow_keys flow_keys; - u64 time_start, time_spent =3D 0; const struct ethhdr *eth; unsigned int flags =3D 0; u32 retval, duration; void *data; int ret; - u32 i; =20 if (prog->type !=3D BPF_PROG_TYPE_FLOW_DISSECTOR) return -EINVAL; @@ -735,39 +775,15 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog = *prog, ctx.data =3D data; ctx.data_end =3D (__u8 *)data + size; =20 - rcu_read_lock(); - preempt_disable(); - time_start =3D ktime_get_ns(); - for (i =3D 0; i < repeat; i++) { + bpf_test_timer_enter(&t); + do { retval =3D bpf_flow_dissect(prog, &ctx, eth->h_proto, ETH_HLEN, size, flags); + } while (bpf_test_timer_continue(&t, repeat, &ret, &duration)); + bpf_test_timer_leave(&t); =20 - if (signal_pending(current)) { - preempt_enable(); - rcu_read_unlock(); - - ret =3D -EINTR; - goto out; - } - - if (need_resched()) { - time_spent +=3D ktime_get_ns() - time_start; - preempt_enable(); - rcu_read_unlock(); - - cond_resched(); - - rcu_read_lock(); - preempt_disable(); - time_start =3D ktime_get_ns(); - } - } - time_spent +=3D ktime_get_ns() - time_start; - preempt_enable(); - rcu_read_unlock(); - - do_div(time_spent, repeat); - duration =3D time_spent > U32_MAX ? U32_MAX : (u32)time_spent; + if (ret < 0) + goto out; =20 ret =3D bpf_test_finish(kattr, uattr, &flow_keys, sizeof(flow_keys), retval, duration); --=20 2.27.0 From nobody Tue Apr 14 21:26:33 2026 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 DEE1AC00144 for ; Mon, 1 Aug 2022 07:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiHAH3h (ORCPT ); Mon, 1 Aug 2022 03:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiHAH3c (ORCPT ); Mon, 1 Aug 2022 03:29:32 -0400 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC8062F3B8; Mon, 1 Aug 2022 00:29:30 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VL2sBIC_1659338967; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0VL2sBIC_1659338967) by smtp.aliyun-inc.com; Mon, 01 Aug 2022 15:29:27 +0800 From: Tianchen Ding To: Greg Kroah-Hartman , Sasha Levin Cc: Lorenz Bauer , Alexei Starovoitov , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 5.10 2/3] bpf: Add PROG_TEST_RUN support for sk_lookup programs Date: Mon, 1 Aug 2022 15:29:15 +0800 Message-Id: <20220801072916.29586-3-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220801072916.29586-1-dtcccc@linux.alibaba.com> References: <20220801072916.29586-1-dtcccc@linux.alibaba.com> 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: Lorenz Bauer commit 7c32e8f8bc33a5f4b113a630857e46634e3e143b upstream. Allow to pass sk_lookup programs to PROG_TEST_RUN. User space provides the full bpf_sk_lookup struct as context. Since the context includes a socket pointer that can't be exposed to user space we define that PROG_TEST_RUN returns the cookie of the selected socket or zero in place of the socket pointer. We don't support testing programs that select a reuseport socket, since this would mean running another (unrelated) BPF program from the sk_lookup test handler. Signed-off-by: Lorenz Bauer Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20210303101816.36774-3-lmb@cloudflare.com Signed-off-by: Tianchen Ding --- include/linux/bpf.h | 10 ++++ include/uapi/linux/bpf.h | 5 +- net/bpf/test_run.c | 105 +++++++++++++++++++++++++++++++++ net/core/filter.c | 1 + tools/include/uapi/linux/bpf.h | 5 +- 5 files changed, 124 insertions(+), 2 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index f21bc441e3fa..b010d45a1ecd 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1457,6 +1457,9 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog = *prog, int bpf_prog_test_run_raw_tp(struct bpf_prog *prog, const union bpf_attr *kattr, union bpf_attr __user *uattr); +int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, + const union bpf_attr *kattr, + union bpf_attr __user *uattr); bool btf_ctx_access(int off, int size, enum bpf_access_type type, const struct bpf_prog *prog, struct bpf_insn_access_aux *info); @@ -1671,6 +1674,13 @@ static inline int bpf_prog_test_run_flow_dissector(s= truct bpf_prog *prog, return -ENOTSUPP; } =20 +static inline int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, + const union bpf_attr *kattr, + union bpf_attr __user *uattr) +{ + return -ENOTSUPP; +} + static inline void bpf_map_put(struct bpf_map *map) { } diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 0f39fdcb2273..2a234023821e 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -5007,7 +5007,10 @@ struct bpf_pidns_info { =20 /* User accessible data for SK_LOOKUP programs. Add new fields at the end.= */ struct bpf_sk_lookup { - __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ + union { + __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ + __u64 cookie; /* Non-zero if socket was selected in PROG_TEST_RUN */ + }; =20 __u32 family; /* Protocol family (AF_INET, AF_INET6) */ __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index d2a4f04df1da..f8b231bbbe38 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -10,8 +10,10 @@ #include #include #include +#include #include #include +#include =20 #define CREATE_TRACE_POINTS #include @@ -796,3 +798,106 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog = *prog, kfree(data); return ret; } + +int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, const union bpf_att= r *kattr, + union bpf_attr __user *uattr) +{ + struct bpf_test_timer t =3D { NO_PREEMPT }; + struct bpf_prog_array *progs =3D NULL; + struct bpf_sk_lookup_kern ctx =3D {}; + u32 repeat =3D kattr->test.repeat; + struct bpf_sk_lookup *user_ctx; + u32 retval, duration; + int ret =3D -EINVAL; + + if (prog->type !=3D BPF_PROG_TYPE_SK_LOOKUP) + return -EINVAL; + + if (kattr->test.flags || kattr->test.cpu) + return -EINVAL; + + if (kattr->test.data_in || kattr->test.data_size_in || kattr->test.data_o= ut || + kattr->test.data_size_out) + return -EINVAL; + + if (!repeat) + repeat =3D 1; + + user_ctx =3D bpf_ctx_init(kattr, sizeof(*user_ctx)); + if (IS_ERR(user_ctx)) + return PTR_ERR(user_ctx); + + if (!user_ctx) + return -EINVAL; + + if (user_ctx->sk) + goto out; + + if (!range_is_zero(user_ctx, offsetofend(typeof(*user_ctx), local_port), = sizeof(*user_ctx))) + goto out; + + if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) { + ret =3D -ERANGE; + goto out; + } + + ctx.family =3D (u16)user_ctx->family; + ctx.protocol =3D (u16)user_ctx->protocol; + ctx.dport =3D (u16)user_ctx->local_port; + ctx.sport =3D (__force __be16)user_ctx->remote_port; + + switch (ctx.family) { + case AF_INET: + ctx.v4.daddr =3D (__force __be32)user_ctx->local_ip4; + ctx.v4.saddr =3D (__force __be32)user_ctx->remote_ip4; + break; + +#if IS_ENABLED(CONFIG_IPV6) + case AF_INET6: + ctx.v6.daddr =3D (struct in6_addr *)user_ctx->local_ip6; + ctx.v6.saddr =3D (struct in6_addr *)user_ctx->remote_ip6; + break; +#endif + + default: + ret =3D -EAFNOSUPPORT; + goto out; + } + + progs =3D bpf_prog_array_alloc(1, GFP_KERNEL); + if (!progs) { + ret =3D -ENOMEM; + goto out; + } + + progs->items[0].prog =3D prog; + + bpf_test_timer_enter(&t); + do { + ctx.selected_sk =3D NULL; + retval =3D BPF_PROG_SK_LOOKUP_RUN_ARRAY(progs, ctx, BPF_PROG_RUN); + } while (bpf_test_timer_continue(&t, repeat, &ret, &duration)); + bpf_test_timer_leave(&t); + + if (ret < 0) + goto out; + + user_ctx->cookie =3D 0; + if (ctx.selected_sk) { + if (ctx.selected_sk->sk_reuseport && !ctx.no_reuseport) { + ret =3D -EOPNOTSUPP; + goto out; + } + + user_ctx->cookie =3D sock_gen_cookie(ctx.selected_sk); + } + + ret =3D bpf_test_finish(kattr, uattr, NULL, 0, retval, duration); + if (!ret) + ret =3D bpf_ctx_finish(kattr, uattr, user_ctx, sizeof(*user_ctx)); + +out: + bpf_prog_array_free(progs); + kfree(user_ctx); + return ret; +} diff --git a/net/core/filter.c b/net/core/filter.c index e2b491665775..815edf7bc439 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -10334,6 +10334,7 @@ static u32 sk_lookup_convert_ctx_access(enum bpf_ac= cess_type type, } =20 const struct bpf_prog_ops sk_lookup_prog_ops =3D { + .test_run =3D bpf_prog_test_run_sk_lookup, }; =20 const struct bpf_verifier_ops sk_lookup_verifier_ops =3D { diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index e440cd7f32a6..b9ee2ded381a 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -5006,7 +5006,10 @@ struct bpf_pidns_info { =20 /* User accessible data for SK_LOOKUP programs. Add new fields at the end.= */ struct bpf_sk_lookup { - __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ + union { + __bpf_md_ptr(struct bpf_sock *, sk); /* Selected socket */ + __u64 cookie; /* Non-zero if socket was selected in PROG_TEST_RUN */ + }; =20 __u32 family; /* Protocol family (AF_INET, AF_INET6) */ __u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */ --=20 2.27.0 From nobody Tue Apr 14 21:26:33 2026 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 83FF4C00144 for ; Mon, 1 Aug 2022 07:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbiHAH3l (ORCPT ); Mon, 1 Aug 2022 03:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiHAH3c (ORCPT ); Mon, 1 Aug 2022 03:29:32 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 565B832D8F; Mon, 1 Aug 2022 00:29:31 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R711e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VL2sBJ._1659338968; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0VL2sBJ._1659338968) by smtp.aliyun-inc.com; Mon, 01 Aug 2022 15:29:28 +0800 From: Tianchen Ding To: Greg Kroah-Hartman , Sasha Levin Cc: Lorenz Bauer , Alexei Starovoitov , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 5.10 3/3] selftests: bpf: Don't run sk_lookup in verifier tests Date: Mon, 1 Aug 2022 15:29:16 +0800 Message-Id: <20220801072916.29586-4-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220801072916.29586-1-dtcccc@linux.alibaba.com> References: <20220801072916.29586-1-dtcccc@linux.alibaba.com> 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: Lorenz Bauer commit b4f894633fa14d7d46ba7676f950b90a401504bb upstream. sk_lookup doesn't allow setting data_in for bpf_prog_run. This doesn't play well with the verifier tests, since they always set a 64 byte input buffer. Allow not running verifier tests by setting bpf_test.runs to a negative value and don't run the ctx access case for sk_lookup. We have dedicated ctx access tests so skipping here doesn't reduce coverage. Signed-off-by: Lorenz Bauer Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20210303101816.36774-6-lmb@cloudflare.com Signed-off-by: Tianchen Ding --- tools/testing/selftests/bpf/test_verifier.c | 4 ++-- tools/testing/selftests/bpf/verifier/ctx_sk_lookup.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/se= lftests/bpf/test_verifier.c index a4c55fcb0e7b..0fb92d9a319b 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -100,7 +100,7 @@ struct bpf_test { enum bpf_prog_type prog_type; uint8_t flags; void (*fill_helper)(struct bpf_test *self); - uint8_t runs; + int runs; #define bpf_testdata_struct_t \ struct { \ uint32_t retval, retval_unpriv; \ @@ -1054,7 +1054,7 @@ static void do_test_single(struct bpf_test *test, boo= l unpriv, =20 run_errs =3D 0; run_successes =3D 0; - if (!alignment_prevented_execution && fd_prog >=3D 0) { + if (!alignment_prevented_execution && fd_prog >=3D 0 && test->runs >=3D 0= ) { uint32_t expected_val; int i; =20 diff --git a/tools/testing/selftests/bpf/verifier/ctx_sk_lookup.c b/tools/t= esting/selftests/bpf/verifier/ctx_sk_lookup.c index 2ad5f974451c..fd3b62a084b9 100644 --- a/tools/testing/selftests/bpf/verifier/ctx_sk_lookup.c +++ b/tools/testing/selftests/bpf/verifier/ctx_sk_lookup.c @@ -239,6 +239,7 @@ .result =3D ACCEPT, .prog_type =3D BPF_PROG_TYPE_SK_LOOKUP, .expected_attach_type =3D BPF_SK_LOOKUP, + .runs =3D -1, }, /* invalid 8-byte reads from a 4-byte fields in bpf_sk_lookup */ { --=20 2.27.0