From 51a4710d304dba90cbdaddba87e62300e96ce3ba Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Sat, 6 Jan 2024 16:40:48 +0800 Subject: [PATCH] bpf: Add mptcp_sched_ops CFI ''' The cfi_stubs pointer is added in the commit 2cd3e3772e41 ("x86/cfi,bpf: Fix bpf_struct_ops CFI"), this patch initializes it as dummy stubs __bpf_mptcp_sched_ops. ''' Note: BPF tests on export branch fail with this error: BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 3 PID: 1512 Comm: test_progs Tainted: G W IOE 6.7.0-rc5 #37 Hardware name: LENOVO 4180PG2/4180PG2, BIOS 83ET76WW (1.46 ) 07/05/2013 RIP: 0010:bpf_struct_ops_map_update_elem+0x4ee/0x610 This patch fixes this error. It can be applied after the commit "bpf: Add bpf_mptcp_sched_ops" Signed-off-by: Geliang Tang --- net/mptcp/bpf.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c index b92c9014ac2c43..fb67768aa07daa 100644 --- a/net/mptcp/bpf.c +++ b/net/mptcp/bpf.c @@ -147,6 +147,19 @@ static int bpf_mptcp_sched_init(struct btf *btf) return 0; } +static void __bpf_mptcp_sched_init(struct mptcp_sock *msk) +{ +} + +static void __bpf_mptcp_sched_release(struct mptcp_sock *msk) +{ +} + +static struct mptcp_sched_ops __bpf_mptcp_sched_ops = { + .init = __bpf_mptcp_sched_init, + .release = __bpf_mptcp_sched_release, +}; + struct bpf_struct_ops bpf_mptcp_sched_ops = { .verifier_ops = &bpf_mptcp_sched_verifier_ops, .reg = bpf_mptcp_sched_reg, @@ -155,6 +168,7 @@ struct bpf_struct_ops bpf_mptcp_sched_ops = { .init_member = bpf_mptcp_sched_init_member, .init = bpf_mptcp_sched_init, .name = "mptcp_sched_ops", + .cfi_stubs = &__bpf_mptcp_sched_ops, }; #endif /* CONFIG_BPF_JIT */