Thread (2 messages) 2 messages, 2 authors, 2025-12-04
STALE230d

[PATCH 1/2] bpf: Fix register_bpf_struct_ops() dummy

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2025-12-04 10:29:32
Also in: bpf, linux-rdma, linux-s390, lkml
Subsystem: bpf [core], bpf [general] (safe dynamic programs and tools), the rest · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, Linus Torvalds

If CONFIG_BPF_SYSCALL=y, but CONFIG_BPF_JIT=n:

    net/smc/smc_hs_bpf.c: In function ‘bpf_smc_hs_ctrl_init’:
    include/linux/bpf.h:2068:50: error: statement with no effect [-Werror=unused-value]
     2068 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
	  |                                                  ^~~~~~~~~~~~~~~~
    net/smc/smc_hs_bpf.c:139:16: note: in expansion of macro ‘register_bpf_struct_ops’
      139 |         return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl);
	  |                ^~~~~~~~~~~~~~~~~~~~~~~

As type is not a variable, but a variable type, this cannot be fixed by
just converting register_bpf_struct_ops() into a static inline function.
Hence fix this by introducing a static inline intermediate dummy.

Fixes: f6be98d19985411c ("bpf, net: switch to dynamic registration")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 include/linux/bpf.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 6498be4c44f8c275..bb69905c28a761e7 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2065,7 +2065,11 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc,
 void bpf_map_struct_ops_info_fill(struct bpf_map_info *info, struct bpf_map *map);
 void bpf_struct_ops_desc_release(struct bpf_struct_ops_desc *st_ops_desc);
 #else
-#define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
+static inline int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops)
+{
+	return 0;
+}
+#define register_bpf_struct_ops(st_ops, type) __register_bpf_struct_ops(st_ops)
 static inline bool bpf_try_module_get(const void *data, struct module *owner)
 {
 	return try_module_get(owner);
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help