Re: [bug report] bpf: Add pid filter support for uprobe_multi link

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux