aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/bpf/syscall.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 828518bb947b..56b4b0e08b3b 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -166,13 +166,25 @@ void bpf_map_area_free(void *area)
166 kvfree(area); 166 kvfree(area);
167} 167}
168 168
169static u32 bpf_map_flags_retain_permanent(u32 flags)
170{
171 /* Some map creation flags are not tied to the map object but
172 * rather to the map fd instead, so they have no meaning upon
173 * map object inspection since multiple file descriptors with
174 * different (access) properties can exist here. Thus, given
175 * this has zero meaning for the map itself, lets clear these
176 * from here.
177 */
178 return flags & ~(BPF_F_RDONLY | BPF_F_WRONLY);
179}
180
169void bpf_map_init_from_attr(struct bpf_map *map, union bpf_attr *attr) 181void bpf_map_init_from_attr(struct bpf_map *map, union bpf_attr *attr)
170{ 182{
171 map->map_type = attr->map_type; 183 map->map_type = attr->map_type;
172 map->key_size = attr->key_size; 184 map->key_size = attr->key_size;
173 map->value_size = attr->value_size; 185 map->value_size = attr->value_size;
174 map->max_entries = attr->max_entries; 186 map->max_entries = attr->max_entries;
175 map->map_flags = attr->map_flags; 187 map->map_flags = bpf_map_flags_retain_permanent(attr->map_flags);
176 map->numa_node = bpf_map_attr_numa_node(attr); 188 map->numa_node = bpf_map_attr_numa_node(attr);
177} 189}
178 190