Skip to content
Commit 1af9270e authored by Toke Høiland-Jørgensen's avatar Toke Høiland-Jørgensen Committed by Alexei Starovoitov
Browse files

bpf: disallow attaching modify_return tracing functions to other BPF programs

From the checks and commit messages for modify_return, it seems it was
never the intention that it should be possible to attach a tracing program
with expected_attach_type == BPF_MODIFY_RETURN to another BPF program.
However, check_attach_modify_return() will only look at the function name,
so if the target function starts with "security_", the attach will be
allowed even for bpf2bpf attachment.

Fix this oversight by also blocking the modification if a target program is
supplied.

Fixes: 18644cec ("bpf: Fix use-after-free in fmod_ret check")
Fixes: 6ba43b76

 ("bpf: Attachment verification for BPF_MODIFY_RETURN")
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 84a20d8e
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment