On Tue, Mar 16, 2021 at 2:03 AM Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > On Wed, Mar 10, 2021 at 2:02 PM Florent Revest <revest@xxxxxxxxxxxx> wrote: > > + } else if (arg_type == ARG_PTR_TO_CONST_STR) { > > + struct bpf_map *map = reg->map_ptr; > > + int map_off, i; > > + u64 map_addr; > > + char *map_ptr; > > + > > + if (!map || !bpf_map_is_rdonly(map)) { > > + verbose(env, "R%d does not point to a readonly map'\n", regno); > > + return -EACCES; > > + } > > + > > + if (!tnum_is_const(reg->var_off)) { > > + verbose(env, "R%d is not a constant address'\n", regno); > > + return -EACCES; > > + } > > + > > + if (!map->ops->map_direct_value_addr) { > > + verbose(env, "no direct value access support for this map type\n"); > > + return -EACCES; > > + } > > + > > + err = check_helper_mem_access(env, regno, > > + map->value_size - reg->off, > > + false, meta); > > you expect reg to be PTR_TO_MAP_VALUE, so probably better to directly > use check_map_access(). And double-check that register is of expected > type. just the presence of ref->map_ptr might not be sufficient? Sorry, just making sure I understand your comment correctly, are you suggesting that we: 1- skip the check_map_access_type() currently done by check_helper_mem_access()? or did you implicitly mean that we should call it as well next to check_map_access() ? 2- enforce (reg->type == PTR_TO_MAP_VALUE) even if currently guaranteed by compatible_reg_types, just to stay on the safe side ?