diff mbox series

bpf: fix a warning message in mark_ptr_not_null_reg()

Message ID YCwewjRBJIBm0sew@mwanda (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series bpf: fix a warning message in mark_ptr_not_null_reg() | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Dan Carpenter Feb. 16, 2021, 7:36 p.m. UTC
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@oracle.com>
---
 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

KP Singh Feb. 16, 2021, 9:10 p.m. UTC | #1
On Tue, Feb 16, 2021 at 8:37 PM Dan Carpenter <dan.carpenter@oracle.com> 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@oracle.com>
> ---
>  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.

[...]
Daniel Borkmann Feb. 17, 2021, 12:37 a.m. UTC | #2
On 2/16/21 10:10 PM, KP Singh wrote:
> On Tue, Feb 16, 2021 at 8:37 PM Dan Carpenter <dan.carpenter@oracle.com> 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@oracle.com>
>> ---
>>   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().
diff mbox series

Patch

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");
 	}
 }