2021-04-22 23:57:38

by Florent Revest

[permalink] [raw]
Subject: [PATCH bpf-next 0/2] Simplify bpf_snprintf verifier code

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

Florent Revest (2):
bpf: Notify user if we ever hit a bpf_snprintf verifier bug
bpf: Remove unnecessary map checks for ARG_PTR_TO_CONST_STR

kernel/bpf/verifier.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

--
2.31.1.498.g6c1eba8ee3d-goog


2021-04-22 23:57:41

by Florent Revest

[permalink] [raw]
Subject: [PATCH bpf-next 2/2] bpf: Remove unnecessary map checks for ARG_PTR_TO_CONST_STR

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.

Signed-off-by: Florent Revest <[email protected]>
Reported-by: Alexei Starovoitov <[email protected]>
---
kernel/bpf/verifier.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 59799a9b014a..2579f6fbb5c3 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -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;
}
--
2.31.1.498.g6c1eba8ee3d-goog

2021-04-23 17:02:50

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH bpf-next 0/2] Simplify bpf_snprintf verifier code

On Thu, Apr 22, 2021 at 4:56 PM Florent Revest <[email protected]> wrote:
>
> Alexei requested a couple of cleanups to the bpf_snprintf and
> ARG_PTR_TO_CONST_STR verifier code.

Applied. Thanks