diff -drupN a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
--- a/kernel/bpf/arraymap.c	2018-08-06 17:23:04.000000000 +0300
+++ b/kernel/bpf/arraymap.c	2022-06-12 05:28:14.000000000 +0300
@@ -16,6 +16,9 @@
 #include <linux/filter.h>
 #include <linux/perf_event.h>
 
+#define ARRAY_CREATE_FLAG_MASK \
+	(BPF_F_RDONLY | BPF_F_WRONLY)
+
 static void bpf_array_free_percpu(struct bpf_array *array)
 {
 	int i;
@@ -57,7 +60,8 @@ static struct bpf_map *array_map_alloc(u
 
 	/* check sanity of attributes */
 	if (attr->max_entries == 0 || attr->key_size != 4 ||
-	    attr->value_size == 0 || attr->map_flags)
+	    attr->value_size == 0 ||
+	    attr->map_flags & ~ARRAY_CREATE_FLAG_MASK)
 		return ERR_PTR(-EINVAL);
 
 	if (attr->value_size >= 1 << (KMALLOC_SHIFT_MAX - 1))