Revert "Revert "bpf: program: Refuse non-O_RDWR flags in BPF_OBJ_GET""

This reverts commit 5ae3c4b3f0 and brings
it back into the tree, as the offending CTS test is now fixed up.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ica5eefc4f2bb86482990c0e3f284a0cbd7b38258
This commit is contained in:
Greg Kroah-Hartman
2021-04-23 12:30:26 +02:00
parent e37efb1947
commit 9f16040d22

View File

@@ -543,7 +543,7 @@ int bpf_obj_get_user(const char __user *pathname, int flags)
return PTR_ERR(raw);
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)
ret = bpf_map_new_fd(raw, f_flags);
else if (type == BPF_TYPE_LINK)