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.
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -33,7 +33,7 @@ int netns_bpf_prog_query(const union bpf_attr *attr, · 32 unmodified lines | ||
| 33 | 33 | union bpf_attr __user *uattr); |
| 34 | 34 | int netns_bpf_prog_attach(const union bpf_attr *attr, |
| 35 | 35 | 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); | |
| 37 | 37 | int netns_bpf_link_create(const union bpf_attr *attr, |
| 38 | 38 | struct bpf_prog *prog); |
| 39 | 39 | #else |
| @@ -49,7 +49,8 @@ static inline int netns_bpf_prog_attach(const union bpf_attr *attr, · 9 unmodified lines | ||
| 49 | 49 | return -EOPNOTSUPP; |
| 50 | 50 | } |
| 51 | 51 | |
| 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) | |
| 53 | 54 | { |
| 54 | 55 | return -EOPNOTSUPP; |
| 55 | 56 | } |