From: Martin KaFai Lau <martin.lau@kernel.org>
Date: Fri, 17 Feb 2023 00:41:47 +0000 (-0800)
Subject: bpf: Disable bh in bpf_test_run for xdp and tc prog
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=af2d0d09eabe98b01bf02b236e381edae4209778;p=linux.git

bpf: Disable bh in bpf_test_run for xdp and tc prog

Some of the bpf helpers require bh disabled. eg. The bpf_fib_lookup
helper that will be used in a latter selftest. In particular, it
calls ___neigh_lookup_noref that expects the bh disabled.

This patch disables bh before calling bpf_prog_run[_xdp], so
the testing prog can also use those helpers.

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230217004150.2980689-2-martin.lau@linux.dev
---

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 1ab396a2b87fc..982e81bba6cf2 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -413,10 +413,12 @@ static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat,
 	old_ctx = bpf_set_run_ctx(&run_ctx.run_ctx);
 	do {
 		run_ctx.prog_item = &item;
+		local_bh_disable();
 		if (xdp)
 			*retval = bpf_prog_run_xdp(prog, ctx);
 		else
 			*retval = bpf_prog_run(prog, ctx);
+		local_bh_enable();
 	} while (bpf_test_timer_continue(&t, 1, repeat, &ret, time));
 	bpf_reset_run_ctx(old_ctx);
 	bpf_test_timer_leave(&t);