* [bug report] bpf: Add pid filter support for uprobe_multi link
@ 2023-09-15 7:12 Dan Carpenter
2023-09-15 9:37 ` Jiri Olsa
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-09-15 7:12 UTC (permalink / raw)
To: jolsa; +Cc: bpf
Hello Jiri Olsa,
The patch b733eeade420: "bpf: Add pid filter support for uprobe_multi
link" from Aug 9, 2023 (linux-next), leads to the following Smatch
static checker warning:
kernel/trace/bpf_trace.c:3227 bpf_uprobe_multi_link_attach()
warn: missing error code here? 'get_pid_task()' failed. 'err' = '0'
kernel/trace/bpf_trace.c
3217 err = -EBADF;
3218 goto error_path_put;
3219 }
3220
3221 pid = attr->link_create.uprobe_multi.pid;
3222 if (pid) {
3223 rcu_read_lock();
3224 task = get_pid_task(find_vpid(pid), PIDTYPE_PID);
3225 rcu_read_unlock();
3226 if (!task)
--> 3227 goto error_path_put;
Should this have an error code?
3228 }
3229
3230 err = -ENOMEM;
3231
[ snip ]
3288 err = bpf_link_prime(&link->link, &link_primer);
3289 if (err)
3290 goto error_free;
3291
3292 kvfree(ref_ctr_offsets);
3293 return bpf_link_settle(&link_primer);
3294
3295 error_free:
3296 kvfree(ref_ctr_offsets);
3297 kvfree(uprobes);
3298 kfree(link);
3299 if (task)
3300 put_task_struct(task);
3301 error_path_put:
3302 path_put(&path);
3303 return err;
3304 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [bug report] bpf: Add pid filter support for uprobe_multi link
2023-09-15 7:12 [bug report] bpf: Add pid filter support for uprobe_multi link Dan Carpenter
@ 2023-09-15 9:37 ` Jiri Olsa
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2023-09-15 9:37 UTC (permalink / raw)
To: Dan Carpenter; +Cc: bpf
On Fri, Sep 15, 2023 at 10:12:34AM +0300, Dan Carpenter wrote:
> Hello Jiri Olsa,
>
> The patch b733eeade420: "bpf: Add pid filter support for uprobe_multi
> link" from Aug 9, 2023 (linux-next), leads to the following Smatch
> static checker warning:
>
> kernel/trace/bpf_trace.c:3227 bpf_uprobe_multi_link_attach()
> warn: missing error code here? 'get_pid_task()' failed. 'err' = '0'
>
> kernel/trace/bpf_trace.c
> 3217 err = -EBADF;
> 3218 goto error_path_put;
> 3219 }
> 3220
> 3221 pid = attr->link_create.uprobe_multi.pid;
> 3222 if (pid) {
> 3223 rcu_read_lock();
> 3224 task = get_pid_task(find_vpid(pid), PIDTYPE_PID);
> 3225 rcu_read_unlock();
> 3226 if (!task)
> --> 3227 goto error_path_put;
>
> Should this have an error code?
yes, it should.. I'll send the fix below
thanks,
jirka
---
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index c1c1af63ced2..868008f56fec 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -3223,8 +3223,10 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
rcu_read_lock();
task = get_pid_task(find_vpid(pid), PIDTYPE_PID);
rcu_read_unlock();
- if (!task)
+ if (!task) {
+ err = -ESRCH;
goto error_path_put;
+ }
}
err = -ENOMEM;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-15 9:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-15 7:12 [bug report] bpf: Add pid filter support for uprobe_multi link Dan Carpenter
2023-09-15 9:37 ` Jiri Olsa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox