From 9b5df4cc9a5b7157c015a1708a70c235e1021d3b Mon Sep 17 00:00:00 2001 From: Lorenz Bauer Date: Thu, 5 Oct 2023 13:58:30 +0000 Subject: [PATCH] bpf: Reject replace_bpf_fd in bpf_prog_detach Signed-off-by: Lorenz Bauer Signed-off-by: Daniel Borkmann --- kernel/bpf/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index d77b2f8b93641b..057970edec5f1b 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -3871,6 +3871,8 @@ static int bpf_prog_detach(const union bpf_attr *attr) if (CHECK_ATTR(BPF_PROG_DETACH)) return -EINVAL; + if (attr->replace_bpf_fd) + return -EINVAL; ptype = attach_type_to_prog_type(attr->attach_type); if (bpf_mprog_supported(ptype)) {