Skip to content

Commit 83c10cc

Browse files
lag-linaroborkmann
authored andcommitted
bpf: Ensure correct locking around vulnerable function find_vpid()
The documentation for find_vpid() clearly states: "Must be called with the tasklist_lock or rcu_read_lock() held." Presently we do neither for find_vpid() instance in bpf_task_fd_query(). Add proper rcu_read_lock/unlock() to fix the issue. Fixes: 41bdc4b ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY") Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20220912133855.1218900-1-lee@kernel.org
1 parent a37a325 commit 83c10cc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/bpf/syscall.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4395,7 +4395,9 @@ static int bpf_task_fd_query(const union bpf_attr *attr,
43954395
if (attr->task_fd_query.flags != 0)
43964396
return -EINVAL;
43974397

4398+
rcu_read_lock();
43984399
task = get_pid_task(find_vpid(pid), PIDTYPE_PID);
4400+
rcu_read_unlock();
43994401
if (!task)
44004402
return -ENOENT;
44014403

0 commit comments

Comments
 (0)