bpf: Fix a verifier message for alloc size helper arg
PATCH 1/1 bpf: Fix a verifier message for alloc size helper arg
The error message here is misleading, the argument will be rejected unless it is a known constant.
--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
@@ -4319,7 +4319,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, err =mark_chain_precision (env, regno); }else if (arg_type_is_alloc_size (arg_type)) {if (!tnum_is_const (reg->var_off)) { -verbose (env,"R%d unbounded size, use 'var &= const' or 'if (var < const)'\n" , +verbose (env,"R%d is not a known constant'\n" , regno);return -EACCES ; }
base-commit: e22d7f05e445165e58feddb4e40cc9c0f94453bc
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
Quoted 14 lines · Brendan Jackman
The error message here is misleading, the argument will be rejected unless it is a known constant.
Signed-off-by Brendan Jackman <[email protected]>--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/verifier.c +0
-0
kernel/bpf/verifier.c static int check_func_arg(struct bpf_verifier_env *env, u32 arg, · line 4322
Quoted 4 lines
kernel/bpf/verifier.c +0
-1@@ -4319,7 +4319,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, err =mark_chain_precision (env, regno); }else if (arg_type_is_alloc_size (arg_type)) {if (!tnum_is_const (reg->var_off)) { - verbose(env, "R%d unbounded size, use 'var &= const' or 'if (var < const)'\n",
Can you check if:
int var = 1000;
var += 1;
if (var < 2000)
// call helper
and then using var in the argument works? If so, the existing error message would be correct.
Quoted 9 lines
kernel/bpf/verifier.c +1
-0+verbose (env,"R%d is not a known constant'\n" , regno);return -EACCES ; }base-commit:
e22d7f05e445165e58feddb4e40cc9c0f94453bc--
2.30.0.284.gd98b1dd5eaa7-goog
Sorry, duplicate - seems I had my mail client in HTML mode the first time around.
Quoted 23 lines · KP Singh
Quoted 14 lines · Brendan Jackman
The error message here is misleading, the argument will be rejected unless it is a known constant.
Signed-off-by Brendan Jackman <[email protected]>--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/verifier.c +0
-0kernel/bpf/verifier.c static int check_func_arg(struct bpf_verifier_env *env, u32 arg, · line 4322
Quoted 4 lines
kernel/bpf/verifier.c +0
-1@@ -4319,7 +4319,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, err =mark_chain_precision (env, regno); }else if (arg_type_is_alloc_size (arg_type)) {if (!tnum_is_const (reg->var_off)) { - verbose(env, "R%d unbounded size, use 'var &= const' or 'if (var < const)'\n",Can you check if:
Quoted 8 lines
int var = 1000;
var += 1;if (var < 2000)
// call helperand then using var in the argument works? If so, the existing error message would be correct.
I think that would work because var is already a known constant before the conditional.. but the error message is still wrong, the if (var < 2000) is irrelevant. If var was not already a known constant (e.g. came from the return value of a bpf_probe_read_kernel_str) it would fail verification.
Quoted 4 lines · Brendan Jackman
The error message here is misleading, the argument will be rejected unless it is a known constant.
Signed-off-by Brendan Jackman <[email protected]>
Okay, this is for bpf_ringbuf_reserve() helper where the size must be a constant.
Quoted 6 lines · Brendan Jackman
The error message here is misleading, the argument will be rejected unless it is a known constant.
Signed-off-by Brendan Jackman <[email protected]>---
LGTM.
Quoted 21 lines
kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/bpf/verifier.c +1
-1@@ -4319,7 +4319,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, err =mark_chain_precision (env, regno); }else if (arg_type_is_alloc_size (arg_type)) {if (!tnum_is_const (reg->var_off)) { -verbose (env,"R%d unbounded size, use 'var &= const' or 'if (var < const)'\n" , +verbose (env,"R%d is not a known constant'\n" , regno);return -EACCES ; }base-commit:
e22d7f05e445165e58feddb4e40cc9c0f94453bc--
2.30.0.284.gd98b1dd5eaa7-goog
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Quoted 9 lines · On Tue, 12 Jan 2021 12:39:13 +0000 you wrote:
The error message here is misleading, the argument will be rejected unless it is a known constant.
Signed-off-by Brendan Jackman <[email protected]>--- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)[...]
Here is the summary with links:
- [bpf-next] bpf: Fix a verifier message for alloc size helper arg
https://git.kernel.org/bpf/bpf-next/c/28a8add64181
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html