Skip to content

Commit

Permalink
bpf: Remove unnecessary map checks for ARG_PTR_TO_CONST_STR
Browse files Browse the repository at this point in the history
reg->type is enforced by check_reg_type() and map should never be NULL
(it would already have been dereferenced anyway) so these checks are
unnecessary.

Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Florent Revest <revest@chromium.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210422235543.4007694-3-revest@chromium.org
  • Loading branch information
FlorentRevest authored and Alexei Starovoitov committed Apr 23, 2021
1 parent 8e8ee10 commit a8fad73
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a8fad73

Please sign in to comment.