Commit d37300ed authored by Lorenz Bauer's avatar Lorenz Bauer Committed by Alexei Starovoitov

bpf: program: Refuse non-O_RDWR flags in BPF_OBJ_GET

As for bpf_link, refuse creating a non-O_RDWR fd. Since program fds
currently don't allow modifications this is a precaution, not a
straight up bug fix.
Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210326160501.46234-2-lmb@cloudflare.com
parent 25fc94b2
...@@ -543,7 +543,7 @@ int bpf_obj_get_user(const char __user *pathname, int flags) ...@@ -543,7 +543,7 @@ int bpf_obj_get_user(const char __user *pathname, int flags)
return PTR_ERR(raw); return PTR_ERR(raw);
if (type == BPF_TYPE_PROG) if (type == BPF_TYPE_PROG)
ret = bpf_prog_new_fd(raw); ret = (f_flags != O_RDWR) ? -EINVAL : bpf_prog_new_fd(raw);
else if (type == BPF_TYPE_MAP) else if (type == BPF_TYPE_MAP)
ret = bpf_map_new_fd(raw, f_flags); ret = bpf_map_new_fd(raw, f_flags);
else if (type == BPF_TYPE_LINK) else if (type == BPF_TYPE_LINK)
......
Markdown is supported
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