History

bpf: flow_dissector: Check value of unused flags to BPF_PROG_DETACH

Using BPF_PROG_DETACH on a flow dissector program supports neither attach_flags nor attach_bpf_fd. Yet no value is enforced for them. Enforce that attach_flags are zero, and require the current program to be passed via attach_bpf_fd. This allows us to remove the check for CAP_SYS_ADMIN, since userspace can now no longer remove arbitrary flow dissector programs.

Lorenz Bauer committed 6 years ago

Commit 4ac2add1 parent 1b514233 files · +19 −9Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/bpf-netns.h+3−2
@@ -33,7 +33,7 @@ int netns_bpf_prog_query(const union bpf_attr *attr, · 32 unmodified lines
3333 union bpf_attr __user *uattr);
3434 int netns_bpf_prog_attach(const union bpf_attr *attr,
3535 struct bpf_prog *prog);
36−int netns_bpf_prog_detach(const union bpf_attr *attr);
36+int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
3737 int netns_bpf_link_create(const union bpf_attr *attr,
3838 struct bpf_prog *prog);
3939 #else
@@ -49,7 +49,8 @@ static inline int netns_bpf_prog_attach(const union bpf_attr *attr, · 9 unmodified lines
4949 return -EOPNOTSUPP;
5050 }
5151
52−static inline int netns_bpf_prog_detach(const union bpf_attr *attr)
52+static inline int netns_bpf_prog_detach(const union bpf_attr *attr,
53+ enum bpf_prog_type ptype)
5354 {
5455 return -EOPNOTSUPP;
5556 }