On Thu, Nov 17, 2022 at 06:21:00PM -0800, Alexei Starovoitov wrote: [...] > > +static inline int tasks_kfunc_map_insert(struct task_struct *p) > > +{ > > + struct __tasks_kfunc_map_value local, *v; > > + long status; > > + struct task_struct *acquired, *old; > > + s32 pid; > > + > > + status = bpf_probe_read_kernel(&pid, sizeof(pid), &p->pid); > > + if (status) > > + return status; > > + > > + local.task = NULL; > > + status = bpf_map_update_elem(&__tasks_kfunc_map, &pid, &local, BPF_NOEXIST); > > + if (status) > > + return status; > > + > > + v = bpf_map_lookup_elem(&__tasks_kfunc_map, &pid); > > + if (!v) { > > + bpf_map_delete_elem(&__tasks_kfunc_map, &pid); > > + return status; > > here it will return 0, but probably should be returning error? Ah, yes this should be returning -ENOENT. Thanks for catching this. [...] > > +SEC("tp_btf/task_newtask") > > +int BPF_PROG(task_kfunc_release_null, struct task_struct *task, u64 clone_flags) > > +{ > > + struct __tasks_kfunc_map_value local, *v; > > + long status; > > + struct task_struct *acquired, *old; > > + s32 pid; > > + > > + status = bpf_probe_read_kernel(&pid, sizeof(pid), &task->pid); > > + if (status) > > + return 0; > > + > > + local.task = NULL; > > + status = bpf_map_update_elem(&__tasks_kfunc_map, &pid, &local, BPF_NOEXIST); > > + if (status) > > + return status; > > + > > + v = bpf_map_lookup_elem(&__tasks_kfunc_map, &pid); > > + if (!v) > > + return status; > > should be return error instead? Yep, here as well. I'll fix both of these in v8. [...]