]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bpf: Export necessary symbols for modules with struct_ops
authorD. Wythe <alibuda@linux.alibaba.com>
Fri, 7 Nov 2025 03:56:30 +0000 (11:56 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 10 Nov 2025 19:07:34 +0000 (11:07 -0800)
Exports three necessary symbols for implementing struct_ops with
tristate subsystem.

To hold or release refcnt of struct_ops refcnt by inline funcs
bpf_try_module_get and bpf_module_put which use bpf_struct_ops_get(put)
conditionally.

And to copy obj name from one to the other with effective checks by
bpf_obj_name_cpy.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20251107035632.115950-2-alibuda@linux.alibaba.com
kernel/bpf/bpf_struct_ops.c
kernel/bpf/syscall.c

index a41e6730edcf33323f5f0831cc520196f9992bc9..278490683d28822c194162ba2c115e8a50dbdc87 100644 (file)
@@ -1162,6 +1162,7 @@ bool bpf_struct_ops_get(const void *kdata)
        map = __bpf_map_inc_not_zero(&st_map->map, false);
        return !IS_ERR(map);
 }
+EXPORT_SYMBOL_GPL(bpf_struct_ops_get);
 
 void bpf_struct_ops_put(const void *kdata)
 {
@@ -1173,6 +1174,7 @@ void bpf_struct_ops_put(const void *kdata)
 
        bpf_map_put(&st_map->map);
 }
+EXPORT_SYMBOL_GPL(bpf_struct_ops_put);
 
 u32 bpf_struct_ops_id(const void *kdata)
 {
index 8a129746bd6cc77c3eea8ce5abd500f99a81326c..80b86e9d3c39bc6657d7f039818d00d6025bf8dc 100644 (file)
@@ -1234,6 +1234,7 @@ int bpf_obj_name_cpy(char *dst, const char *src, unsigned int size)
 
        return src - orig_src;
 }
+EXPORT_SYMBOL_GPL(bpf_obj_name_cpy);
 
 int map_check_no_btf(const struct bpf_map *map,
                     const struct btf *btf,