bpf: Do not allow map_freeze in struct_ops map
authorMartin KaFai Lau <kafai@fb.com>
Thu, 5 Mar 2020 01:34:54 +0000 (17:34 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 5 Mar 2020 22:15:49 +0000 (14:15 -0800)
struct_ops map cannot support map_freeze.  Otherwise, a struct_ops
cannot be unregistered from the subsystem.

Fixes: 85d33df357b6 ("bpf: Introduce BPF_MAP_TYPE_STRUCT_OPS")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200305013454.535397-1-kafai@fb.com
kernel/bpf/syscall.c

index a91ad518c050335be6c751296c42149752e7c2fe..0c7fb0d4836d38677dda7e2d6067476e6d086498 100644 (file)
@@ -1510,6 +1510,11 @@ static int map_freeze(const union bpf_attr *attr)
        if (IS_ERR(map))
                return PTR_ERR(map);
 
+       if (map->map_type == BPF_MAP_TYPE_STRUCT_OPS) {
+               fdput(f);
+               return -ENOTSUPP;
+       }
+
        mutex_lock(&map->freeze_mutex);
 
        if (map->writecnt) {