On Mon, Apr 25, 2022 at 03:18:51AM +0530, Kumar Kartikeya Dwivedi wrote: > + > +static u32 bpf_kptr_xchg_btf_id; > + > +const struct bpf_func_proto bpf_kptr_xchg_proto = { > + .func = bpf_kptr_xchg, > + .gpl_only = false, > + .ret_type = RET_PTR_TO_BTF_ID_OR_NULL, > + .ret_btf_id = &bpf_kptr_xchg_btf_id, > + .arg1_type = ARG_PTR_TO_KPTR, > + .arg2_type = ARG_PTR_TO_BTF_ID_OR_NULL | OBJ_RELEASE, > + .arg2_btf_id = &bpf_kptr_xchg_btf_id, > +}; I've tweaked above with: +/* Unlike other PTR_TO_BTF_ID helpers the btf_id in bpf_kptr_xchg() + * helper is determined dynamically by the verifier. + */ +#define BPF_PTR_POISON ((void *)((0xeB9FUL << 2) + POISON_POINTER_DELTA)) + +const struct bpf_func_proto bpf_kptr_xchg_proto = { + .func = bpf_kptr_xchg, + .gpl_only = false, + .ret_type = RET_PTR_TO_BTF_ID_OR_NULL, + .ret_btf_id = BPF_PTR_POISON, + .arg1_type = ARG_PTR_TO_KPTR, + .arg2_type = ARG_PTR_TO_BTF_ID_OR_NULL | OBJ_RELEASE, + .arg2_btf_id = BPF_PTR_POISON,