summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFlorent Revest <revest@chromium.org>2021-04-23 02:55:42 +0300
committerAlexei Starovoitov <ast@kernel.org>2021-04-23 19:58:21 +0300
commit8e8ee109b02c0e90021d63cd20dd0157c021f7a4 (patch)
tree8abf8acf65295cbadcaeea0b76b1437f02c7e535 /kernel
parente7a1c1300891d8f11d05b42665e299cc22a4b383 (diff)
downloadlinux-8e8ee109b02c0e90021d63cd20dd0157c021f7a4.tar.xz
bpf: Notify user if we ever hit a bpf_snprintf verifier bug
In check_bpf_snprintf_call(), a map_direct_value_addr() of the fmt map should never fail because it has already been checked by ARG_PTR_TO_CONST_STR. But if it ever fails, it's better to error out with an explicit debug message rather than silently fail. 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-2-revest@chromium.org
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/verifier.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 58730872f7e5..59799a9b014a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -5940,8 +5940,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