@@ -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;
};
@@ -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)
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(-)