Re: [PATCH] bpf: fix a warning message in mark_ptr_not_null_reg()

From: Daniel Borkmann
Date: Tue Feb 16 2021 - 19:40:38 EST


On 2/16/21 10:10 PM, KP Singh wrote:
On Tue, Feb 16, 2021 at 8:37 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:

The WARN_ON() argument is a condition, and it generates a stack trace
but it doesn't print the warning.

Fixes: 4ddb74165ae5 ("bpf: Extract nullable reg type conversion into a helper function")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
kernel/bpf/verifier.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 056df6be3e30..bd4d1dfca73c 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1120,7 +1120,7 @@ static void mark_ptr_not_null_reg(struct bpf_reg_state *reg)
reg->type = PTR_TO_RDWR_BUF;
break;
default:
- WARN_ON("unknown nullable register type");
+ WARN(1, "unknown nullable register type");

Should we use WARN_ONCE here? Also, I think the fix should be targeted
for bpf-next as
the patch that introduced this hasn't made it to bpf yet.

[...]

Usually we have something like `verbose(env, "kernel subsystem misconfigured verifier\n")`,
but in this case we'd need to drag env all the way to here. :/ I agree with WARN_ONCE().