Re: fix u32 printf specifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/06/2021 19:41, Martin KaFai Lau wrote:

On Wed, Jun 02, 2021 at 05:23:19PM +0200, Benedict Schlueter wrote:
Hi,

I assume its clear what this patch does.


 From 9618e4475b812651c3fe481af885757675fc4ae2 Mon Sep 17 00:00:00 2001
From: Benedict Schlueter <benedict.schlueter@xxxxxx>
Date: Wed, 2 Jun 2021 17:16:13 +0200
Subject: use correct format string specifier for unsigned 32 Bit
  bounds print statements

Signed-off-by: Benedict Schlueter <benedict.schlueter@xxxxxx>
---
  kernel/bpf/verifier.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 1de4b8c6ee42..e107996c7220 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -690,11 +690,11 @@ static void print_verifier_state(struct
bpf_verifier_env *env,
                          (int)(reg->s32_max_value));
                  if (reg->u32_min_value != reg->umin_value &&
                      reg->u32_min_value != U32_MIN)
-                    verbose(env, ",u32_min_value=%d",
+                    verbose(env, ",u32_min_value=%u",
                          (int)(reg->u32_min_value));
"%u" and (int) cast don't make sense.
Yep, changed to unsigned int for consistency with the other cases. Is this necessary? Since reg->u32_min_value is already a unsigned 32 bit number.
It needs a proper commit message to explain why the change is needed
and also a Fixes tag.  Please refer to Documentation/bpf/bpf_devel_QA.rst.

Sorry should have read this more carefully before. Everything should be included right now.

From fd076dc5f2bd5ec4e9cb49530e77cf2d3e4f42c2 Mon Sep 17 00:00:00 2001
From: Benedict Schlueter <benedict.schlueter@xxxxxx>
Date: Wed, 2 Jun 2021 21:42:39 +0200
Subject: [PATCH bpf-next]
 use correct format string specifier for unsigned 32 bounds

when printing an unsigned value, it should be a positive number

verifier log before the patch
([...],s32_max_value=-2,u32_min_value=-16,u32_max_value=-2)

verifier log after the patch
([...],s32_max_value=-2,u32_min_value=4294967280,u32_max_value=4294967294)


fixes 3f50f132d840 (bpf: Verifier, do explicit ALU32 bounds tracking)
Signed-off-by: Benedict Schlueter <benedict.schlueter@xxxxxx>
---
 kernel/bpf/verifier.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 1de4b8c6ee42..ea482ebaeb26 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -690,12 +690,12 @@ static void print_verifier_state(struct bpf_verifier_env *env,
                         (int)(reg->s32_max_value));
                 if (reg->u32_min_value != reg->umin_value &&
                     reg->u32_min_value != U32_MIN)
-                    verbose(env, ",u32_min_value=%d",
-                        (int)(reg->u32_min_value));
+                    verbose(env, ",u32_min_value=%u",
+                        (unsigned int)(reg->u32_min_value));
                 if (reg->u32_max_value != reg->umax_value &&
                     reg->u32_max_value != U32_MAX)
-                    verbose(env, ",u32_max_value=%d",
-                        (int)(reg->u32_max_value));
+                    verbose(env, ",u32_max_value=%u",
+                        (unsigned int)(reg->u32_max_value));
             }
             verbose(env, ")");
         }
--
2.31.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux