diff mbox series

[bpf-next,5/9] bpf: Allow registration of const cfi_stubs

Message ID 20241127-bpf-const-ops-v1-5-a698b8d58680@weissschuh.net (mailing list archive)
State New
Headers show
Series bpf: Constify BPF ops | expand

Commit Message

Thomas Weißschuh Nov. 27, 2024, 7:15 p.m. UTC
The BPF core does not need to modify the cfi_stubs.
Reflect this in the API so users can move their structures into
read-only memory.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 include/linux/bpf.h         | 2 +-
 kernel/bpf/bpf_struct_ops.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index a9267af9671b2bc8961cde24d2f79f473ab227d7..fbe5ae7c2b380fdb624ea1f04fdf56e4f6710f14 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1795,7 +1795,7 @@  struct bpf_struct_ops {
 	void (*unreg)(void *kdata, struct bpf_link *link);
 	int (*update)(void *kdata, void *old_kdata, struct bpf_link *link);
 	int (*validate)(void *kdata);
-	void *cfi_stubs;
+	const void *cfi_stubs;
 	struct module *owner;
 	const char *name;
 };
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index 967f0914d473fcde4a6ce3bb6ac976345daf8e88..2a9b9c39f1e7c2c22dc83ad68766b522117f3979 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -778,7 +778,7 @@  static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
 		trampoline_start = image_off;
 		err = bpf_struct_ops_prepare_trampoline(tlinks, link,
 						&st_ops_desc->func_models[i],
-						*(void **)(st_ops->cfi_stubs + moff),
+						*(void *const *)(st_ops->cfi_stubs + moff),
 						&image, &image_off,
 						st_map->image_pages_cnt < MAX_TRAMP_IMAGE_PAGES);
 		if (err)