Skip to contentSkip to conversation

bpf: fix a warning message in mark_ptr_not_null_reg()

PATCH Superseded Dan Carpenter 4 participants 5 messages Feb 16, 2021 – Feb 17, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: fix a warning message in mark_ptr_not_null_reg()

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")
---
 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
index 056df6be3e30..bd4d1dfca73c 100644
@@ -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");
 	}
 }
 
Signature · 1 line
2.30.0
#1 lore raw
Quoted 15 lines · Dan Carpenter

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")
---
 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +0 -0
index 056df6be3e30..bd4d1dfca73c 100644

kernel/bpf/verifier.c static void mark_ptr_not_null_reg(struct bpf_reg_state *reg) · line 1123

Quoted 5 lines
kernel/bpf/verifier.c +1 -1
@@ -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.

[...]

maintainer
#2 lore raw
Quoted 26 lines · KP Singh
Quoted 15 lines · Dan Carpenter

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")
---
  kernel/bpf/verifier.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +0 -0
index 056df6be3e30..bd4d1dfca73c 100644

kernel/bpf/verifier.c static void mark_ptr_not_null_reg(struct bpf_reg_state *reg) · line 1123

Quoted 5 lines
kernel/bpf/verifier.c +1 -1
@@ -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.

Quoted 1 line

[...]

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().

#3 lore raw

PATCH v2 1/1 bpf: fix a warning message in mark_ptr_not_null_reg()

The WARN_ON() argument is a condition, not an error message. So this code will print a stack trace but will not print the warning message. Fix that and also change it to only WARN_ONCE().

Fixes 4ddb74165ae5 ("bpf: Extract nullable reg type conversion into a helper function")

---
v2: Use WARN_ONCE().

 kernel/bpf/verifier.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
index 1dda9d81f12c..3d34ba492d46 100644
@@ -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_ONCE(1, "unknown nullable register type");
 	}
 }
 
Signature · 1 line
2.30.0
#4 lore raw
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 8 lines · On Wed, 17 Feb 2021 10:45:25 +0300 you wrote:

The WARN_ON() argument is a condition, not an error message. So this code will print a stack trace but will not print the warning message. Fix that and also change it to only WARN_ONCE().

Fixes 4ddb74165ae5 ("bpf: Extract nullable reg type conversion into a helper function")

[...]

Here is the summary with links:
- [v2,bpf-next] bpf: fix a warning message in mark_ptr_not_null_reg()

    https://git.kernel.org/bpf/bpf-next/c/7b1e385c9a48

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html