Merge branch 'Simplify bpf_snprintf verifier code'
Florent Revest says: ==================== Alexei requested a couple of cleanups to the bpf_snprintf and ARG_PTR_TO_CONST_STR verifier code. https://lore.kernel.org/bpf/CABRcYmL_SMT80UTyV98bRsOzW0wBd1sZcYUpTrcOAV+9m+YoWQ@mail.gmail.com/T/#t ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
b1b9f535c4
@ -5075,8 +5075,7 @@ skip_type_check:
|
|||||||
u64 map_addr;
|
u64 map_addr;
|
||||||
char *str_ptr;
|
char *str_ptr;
|
||||||
|
|
||||||
if (reg->type != PTR_TO_MAP_VALUE || !map ||
|
if (!bpf_map_is_rdonly(map)) {
|
||||||
!bpf_map_is_rdonly(map)) {
|
|
||||||
verbose(env, "R%d does not point to a readonly map'\n", regno);
|
verbose(env, "R%d does not point to a readonly map'\n", regno);
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
@ -5940,8 +5939,10 @@ static int check_bpf_snprintf_call(struct bpf_verifier_env *env,
|
|||||||
fmt_map_off = fmt_reg->off + fmt_reg->var_off.value;
|
fmt_map_off = fmt_reg->off + fmt_reg->var_off.value;
|
||||||
err = fmt_map->ops->map_direct_value_addr(fmt_map, &fmt_addr,
|
err = fmt_map->ops->map_direct_value_addr(fmt_map, &fmt_addr,
|
||||||
fmt_map_off);
|
fmt_map_off);
|
||||||
if (err)
|
if (err) {
|
||||||
return err;
|
verbose(env, "verifier bug\n");
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
fmt = (char *)(long)fmt_addr + fmt_map_off;
|
fmt = (char *)(long)fmt_addr + fmt_map_off;
|
||||||
|
|
||||||
/* We are also guaranteed that fmt+fmt_map_off is NULL terminated, we
|
/* We are also guaranteed that fmt+fmt_map_off is NULL terminated, we
|
||||||
|
Loading…
Reference in New Issue
Block a user