From 9f16040d22b10202b4acdf32336ea2aacbe556ea Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 23 Apr 2021 12:30:26 +0200 Subject: [PATCH] Revert "Revert "bpf: program: Refuse non-O_RDWR flags in BPF_OBJ_GET"" This reverts commit 5ae3c4b3f0b157506a0d80f0452b7745459dc198 and brings it back into the tree, as the offending CTS test is now fixed up. Signed-off-by: Greg Kroah-Hartman Change-Id: Ica5eefc4f2bb86482990c0e3f284a0cbd7b38258 --- kernel/bpf/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 80da1db47c68..b4ebd60a6c16 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -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)