]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bpf: Check the validity of max_rdwr_access for sock local storage map iterator
authorHou Tao <houtao1@huawei.com>
Wed, 10 Aug 2022 08:05:34 +0000 (16:05 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 10 Aug 2022 17:12:48 +0000 (10:12 -0700)
The value of sock local storage map is writable in map iterator, so check
max_rdwr_access instead of max_rdonly_access.

Fixes: 8278de68a482 ("bpf: Implement bpf iterator for sock local storage map")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/r/20220810080538.1845898-6-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/bpf_sk_storage.c

index 83b89ba824d71f85a429bb29a354d8fd35fa8c20..1b7f385643b4c90c02f0659e64d2f5d371f839dc 100644 (file)
@@ -904,7 +904,7 @@ static int bpf_iter_attach_map(struct bpf_prog *prog,
        if (map->map_type != BPF_MAP_TYPE_SK_STORAGE)
                goto put_map;
 
-       if (prog->aux->max_rdonly_access > map->value_size) {
+       if (prog->aux->max_rdwr_access > map->value_size) {
                err = -EACCES;
                goto put_map;
        }