lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Nov 2022 08:49:56 -0600
From:   David Vernet <void@...ifault.com>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc:     bpf@...r.kernel.org, ast@...nel.org, andrii@...nel.org,
        daniel@...earbox.net, martin.lau@...ux.dev, memxor@...il.com,
        yhs@...com, song@...nel.org, sdf@...gle.com,
        john.fastabend@...il.com, kpsingh@...nel.org, jolsa@...nel.org,
        haoluo@...gle.com, tj@...nel.org, kernel-team@...com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next v7 3/3] bpf/selftests: Add selftests for new
 task kfuncs

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.

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ