On Sun, Aug 27, 2023 at 08:27:44AM -0700, Yonghong Song wrote: > case KF_ARG_PTR_TO_ALLOC_BTF_ID: > - if (reg->type != (PTR_TO_BTF_ID | MEM_ALLOC)) { > + if (reg->type == (PTR_TO_BTF_ID | MEM_ALLOC)) { > + if (meta->func_id != special_kfunc_list[KF_bpf_obj_drop_impl]) { > + verbose(env, "arg#%d expected for bpf_obj_drop_impl()\n", i); > + return -EINVAL; > + } > + } else if (reg->type == (PTR_TO_BTF_ID | MEM_ALLOC | MEM_PERCPU)) { > + if (meta->func_id != special_kfunc_list[KF_bpf_percpu_obj_drop_impl]) { > + verbose(env, "arg#%d expected for bpf_percpu_obj_drop_impl()\n", i); > + return -EINVAL; > + } > + } else { > verbose(env, "arg#%d expected pointer to allocated object\n", i); > return -EINVAL; This is a bit too much of hard coded checks for "suppose to be generic" __alloc arg suffix in kfuncs. We only have two such kfuncs: bpf_percpu_obj_drop_impl(void *p__alloc bpf_obj_drop_impl(void *p__alloc so above works and I don't have a good suggestion how it can be improved, but would be great to follow up to clean this up somehow.