Commit b1b9f535 authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

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: default avatarAlexei Starovoitov <ast@kernel.org>
parents e7a1c130 a8fad73e
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -5075,8 +5075,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
		u64 map_addr;
		char *str_ptr;

		if (reg->type != PTR_TO_MAP_VALUE || !map ||
		    !bpf_map_is_rdonly(map)) {
		if (!bpf_map_is_rdonly(map)) {
			verbose(env, "R%d does not point to a readonly map'\n", regno);
			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;
	err = fmt_map->ops->map_direct_value_addr(fmt_map, &fmt_addr,
						  fmt_map_off);
	if (err)
		return err;
	if (err) {
		verbose(env, "verifier bug\n");
		return -EFAULT;
	}
	fmt = (char *)(long)fmt_addr + fmt_map_off;

	/* We are also guaranteed that fmt+fmt_map_off is NULL terminated, we