bpf: Ensure correct locking around vulnerable function find_vpid()
PATCH v3 1/1 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.
---
v2 => v3:
* Changed strategy from find_get_pid() to rcu_read_{un}lock()
* Removed Jiri's Ack
v1 => v2:
* Commit log update - no code differences
kernel/bpf/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bpf/syscall.c +2 -0
@@ -4399,7 +4399,9 @@ static int bpf_task_fd_query(const union bpf_attr *attr,if (attr->task_fd_query.flags !=0 )return -EINVAL ; +rcu_read_lock (); task =get_pid_task (find_vpid (pid),PIDTYPE_PID ); +rcu_read_unlock ();if (!task)return -ENOENT ;
Signature · 1 line
2.37.2.789.g6183377224-goog
Quoted 2 lines · Lee Jones
The documentation for
find_vpid()clearly states:
No need for the above extra line.
Quoted 3 lines
"Must be called with the
tasklist_lockorrcu_read_lock()held."Presently we do neither.
Presently we do neither for find_vpid() instance in bpf_task_fd_query(). Add proper rcu_read_lock/unlock() to fix the issue.
Quoted 15 lines
Cc Jiri Olsa <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc John Fastabend <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc KP Singh <[email protected]>Cc Stanislav Fomichev <[email protected]>Cc Hao Luo <[email protected]>Fixes 41bdc4b40ed6f ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY")Signed-off-by Lee Jones <[email protected]>
Ack with above a few suggestions for the commit message.
Quoted 5 lines · Yonghong Song
Quoted 2 lines · Lee Jones
The documentation for
find_vpid()clearly states:No need for the above extra line.
The intentional blank formatting line?
The commit message would look worse without it.
Is this really a blocker?
Quoted 6 lines
Quoted 3 lines
"Must be called with the
tasklist_lockorrcu_read_lock()held."Presently we do neither.
Presently we do neither for
find_vpid()instance inbpf_task_fd_query(). Add proper rcu_read_lock/unlock() to fix the issue.
I can expand this.
Quoted 18 lines
Quoted 6 lines
Cc Jiri Olsa <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc John Fastabend <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Quoted 8 lines
Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc KP Singh <[email protected]>Cc Stanislav Fomichev <[email protected]>Cc Hao Luo <[email protected]>Fixes 41bdc4b40ed6f ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY")Signed-off-by Lee Jones <[email protected]>Ack with above a few suggestions for the commit message.
Acked-by Yonghong Song <[email protected]>
Signature · 1 line
Lee Jones [李琼斯]
Quoted 5 lines · Lee Jones
Quoted 4 lines · Yonghong Song
Quoted 2 lines · Lee Jones
The documentation for
find_vpid()clearly states:
Quoted 7 lines
Quoted 1 line
No need for the above extra line.
The intentional blank formatting line?
The commit message would look worse without it.
Is this really a blocker?
Not a blocker. Just a suggestion. I won't enforce it if you do have this extra line.
Quoted 29 lines
Quoted 7 lines
Quoted 4 lines
"Must be called with the
tasklist_lockorrcu_read_lock()held."Presently we do neither.
Presently we do neither for
find_vpid()instance inbpf_task_fd_query(). Add proper rcu_read_lock/unlock() to fix the issue.I can expand this.
Quoted 18 lines
Quoted 6 lines
Cc Jiri Olsa <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc John Fastabend <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Quoted 8 lines
Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc KP Singh <[email protected]>Cc Stanislav Fomichev <[email protected]>Cc Hao Luo <[email protected]>Fixes 41bdc4b40ed6f ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY")Signed-off-by Lee Jones <[email protected]>Ack with above a few suggestions for the commit message.
Acked-by Yonghong Song <[email protected]>
This patch was applied to bpf/bpf.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <[email protected]>:
Quoted 21 lines · On Mon, 12 Sep 2022 14:38:55 +0100 you wrote:
The documentation for
find_vpid()clearly states:"Must be called with the
tasklist_lockorrcu_read_lock()held."Presently we do neither.
Cc Jiri Olsa <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>Cc John Fastabend <[email protected]>Cc Andrii Nakryiko <[email protected]>Cc Martin KaFai Lau <[email protected]>Cc Song Liu <[email protected]>Cc Yonghong Song <[email protected]>Cc KP Singh <[email protected]>Cc Stanislav Fomichev <[email protected]>Cc Hao Luo <[email protected]>Fixes 41bdc4b40ed6f ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY")Signed-off-by Lee Jones <[email protected]>
Quoted 1 line
[...]
Here is the summary with links:
- [v3,1/1] bpf: Ensure correct locking around vulnerable function find_vpid()
https://git.kernel.org/bpf/bpf/c/83c10cc362d9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html