Skip to contentSkip to conversation

kernel/bpf/verifier.c:619 mark_stack_slot_scratched() warn: should '1 << spi' be a 64 bit type?

PATCH In review Dan Carpenter 5 participants 7 messages Jan 6, 2022 – Jan 11, 2022

Subsystems (3)
lore
Share & tools
lore

Dan Carpenter

author build bot
#0 lore raw

CC: kbuild-all(a)lists.01.org
CC: Linux Memory Management List <[email protected]>
TO: Christy Lee <[email protected]>
CC: Alexei Starovoitov <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   7a769a3922d81cfc74ab4d90a9cc69485f260976
commit: 0f55f9ed21f96630c6ec96805d42f92c0b458b37 [7391/10864] bpf: Only print scratched registers and stack slots to verifier logs.

:::::: branch date: 16 hours ago
:::::: commit date: 3 weeks ago
config: xtensa-randconfig-m031-20220105 (https://download.01.org/0day-ci/archive/20220106/202201060848.nagWejwv-lkp(a)intel.com/config)
compiler: xtensa-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
kernel/bpf/verifier.c:619 mark_stack_slot_scratched() warn: should '1 << spi' be a 64 bit type?

Old smatch warnings:
arch/xtensa/include/asm/thread_info.h:91 current_thread_info() warn: inconsistent indenting

vim +619 kernel/bpf/verifier.c

0f55f9ed21f9663 Christy Lee 2021-12-16  616  
0f55f9ed21f9663 Christy Lee 2021-12-16  617  static void mark_stack_slot_scratched(struct bpf_verifier_env *env, u32 spi)
0f55f9ed21f9663 Christy Lee 2021-12-16  618  {

0f55f9ed21f9663 Christy Lee 2021-12-16 @619 env->scratched_stack_slots |= 1UL << spi;
0f55f9ed21f9663 Christy Lee 2021-12-16 620 }
0f55f9ed21f9663 Christy Lee 2021-12-16 621

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#1 lore raw

PATCH 1/1 Fix incorrect integer literal used for marking scratched registers in verifier logs

env->scratched_stack_slots is a 64-bit value, we should use ULL instead of UL literal values.

---
 kernel/bpf/verifier.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/verifier.c +3 -3
index bfb45381fb3f..a8587210907d 100644
@@ -616,7 +616,7 @@ static void mark_reg_scratched(struct bpf_verifier_env *env, u32 regno)
 
 static void mark_stack_slot_scratched(struct bpf_verifier_env *env, u32 spi)
 {
-	env->scratched_stack_slots |= 1UL << spi;
+	env->scratched_stack_slots |= 1ULL << spi;
 }
 
 static bool reg_scratched(const struct bpf_verifier_env *env, u32 regno)
@@ -637,14 +637,14 @@ static bool verifier_state_scratched(const struct bpf_verifier_env *env)
 static void mark_verifier_state_clean(struct bpf_verifier_env *env)
 {
 	env->scratched_regs = 0U;
-	env->scratched_stack_slots = 0UL;
+	env->scratched_stack_slots = 0ULL;
 }
 
 /* Used for printing the entire verifier state. */
 static void mark_verifier_state_scratched(struct bpf_verifier_env *env)
 {
 	env->scratched_regs = ~0U;
-	env->scratched_stack_slots = ~0UL;
+	env->scratched_stack_slots = ~0ULL;
 }
 
 /* The reg state of a pointer or a bounded scalar was saved when
Signature · 1 line
2.30.2
reviewer Acked-by on v1 1/1
#2 lore raw

Re: [PATCH bpf-next] Fix incorrect integer literal used for marking scratched registers in verifier logs

Quoted 7 lines · Christy Lee

env->scratched_stack_slots is a 64-bit value, we should use ULL instead of UL literal values.

The fix looks good to me. Thus:

However, the patch looks corrupted. Also, the subject is probably too long (./scripts/checkpatch.pl should complain about it).

Thanks,
Song

Quoted 37 lines
---
 kernel/bpf/verifier.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/verifier.c +3 -4
index bfb45381fb3f..a8587210907d 100644
@@ -616,7 +616,7 @@ static void mark_reg_scratched(struct bpf_verifier_env *env, u32 regno)
 
 static void mark_stack_slot_scratched(struct bpf_verifier_env *env, u32 spi)
 {
-       env->scratched_stack_slots |= 1UL << spi;
+       env->scratched_stack_slots |= 1ULL << spi;
 }
 
 static bool reg_scratched(const struct bpf_verifier_env *env, u32 regno)
@@ -637,14 +637,14 @@ static bool verifier_state_scratched(const struct bpf_verifier_env *env)
 static void mark_verifier_state_clean(struct bpf_verifier_env *env)
 {
        env->scratched_regs = 0U;
-       env->scratched_stack_slots = 0UL;
+       env->scratched_stack_slots = 0ULL;
 }
 
 /* Used for printing the entire verifier state. */
 static void mark_verifier_state_scratched(struct bpf_verifier_env *env)
 {
        env->scratched_regs = ~0U;
-       env->scratched_stack_slots = ~0UL;
+       env->scratched_stack_slots = ~0ULL;
 }
 
 /* The reg state of a pointer or a bounded scalar was saved when
--

2.30.2

#3 lore raw

Re: [PATCH bpf-next] Fix incorrect integer literal used for marking scratched registers in verifier logs

Quoted 10 lines · Song Liu
Quoted 7 lines · Christy Lee

env->scratched_stack_slots is a 64-bit value, we should use ULL instead of UL literal values.

Quoted 7 lines

The fix looks good to me. Thus:

However, the patch looks corrupted. Also, the subject is probably too long (./scripts/checkpatch.pl should complain about it).

I just checked that even with an absurdly long subject (more than 200 characters), ./scripts/checkpatch.pl doesn't complain. It only complains when the commit message body has longer than 75 characters but not the subject line. What's the maximum subject line length?

Christy

Quoted 41 lines

Thanks,
Song

Quoted 37 lines
---
 kernel/bpf/verifier.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/verifier.c +3 -4
index bfb45381fb3f..a8587210907d 100644
@@ -616,7 +616,7 @@ static void mark_reg_scratched(struct bpf_verifier_env *env, u32 regno)
 
 static void mark_stack_slot_scratched(struct bpf_verifier_env *env, u32 spi)
 {
-       env->scratched_stack_slots |= 1UL << spi;
+       env->scratched_stack_slots |= 1ULL << spi;
 }
 
 static bool reg_scratched(const struct bpf_verifier_env *env, u32 regno)
@@ -637,14 +637,14 @@ static bool verifier_state_scratched(const struct bpf_verifier_env *env)
 static void mark_verifier_state_clean(struct bpf_verifier_env *env)
 {
        env->scratched_regs = 0U;
-       env->scratched_stack_slots = 0UL;
+       env->scratched_stack_slots = 0ULL;
 }
 
 /* Used for printing the entire verifier state. */
 static void mark_verifier_state_scratched(struct bpf_verifier_env *env)
 {
        env->scratched_regs = ~0U;
-       env->scratched_stack_slots = ~0UL;
+       env->scratched_stack_slots = ~0ULL;
 }
 
 /* The reg state of a pointer or a bounded scalar was saved when
--

2.30.2

reviewer
#4 lore raw

Re: [PATCH bpf-next] Fix incorrect integer literal used for marking scratched registers in verifier logs

Quoted 16 lines · Christy Lee
Quoted 14 lines · Song Liu
Quoted 7 lines · Christy Lee

env->scratched_stack_slots is a 64-bit value, we should use ULL instead of UL literal values.

The fix looks good to me. Thus:

Quoted 8 lines
Quoted 3 lines

However, the patch looks corrupted. Also, the subject is probably too long (./scripts/checkpatch.pl should complain about it).

I just checked that even with an absurdly long subject (more than 200 characters), ./scripts/checkpatch.pl doesn't complain. It only complains when the commit message body has longer than 75 characters but not the subject line. What's the maximum subject line length?

Hmm.. you are right. I somehow thought there was a limit by checkpatch. I would personally limit it to 75 characters though.

#5 lore raw

Re: [PATCH bpf-next] Fix incorrect integer literal used for marking scratched registers in verifier logs

In reply to Christy Lee
Quoted 15 lines · Christy Lee
Quoted 14 lines · Song Liu
Quoted 7 lines · Christy Lee

env->scratched_stack_slots is a 64-bit value, we should use ULL instead of UL literal values.

The fix looks good to me. Thus:

Quoted 9 lines
Quoted 3 lines

However, the patch looks corrupted. Also, the subject is probably too long (./scripts/checkpatch.pl should complain about it).

I just checked that even with an absurdly long subject (more than 200 characters), ./scripts/checkpatch.pl doesn't complain. It only complains when the commit message body has longer than 75 characters but not the subject line. What's the maximum subject line length?

People say 50 characters but that just seems more aspirational than realistic. This patch needs a subsystem prefix as well.

regards,
dan carpenter

#6 lore raw

Re: [PATCH bpf-next] Fix incorrect integer literal used for marking scratched registers in verifier logs

Quoted 21 lines · Dan Carpenter
Quoted 19 lines · Christy Lee
Quoted 17 lines · Song Liu
Quoted 7 lines · Christy Lee

env->scratched_stack_slots is a 64-bit value, we should use ULL instead of UL literal values.

The fix looks good to me. Thus:

However, the patch looks corrupted. Also, the subject is probably too long (./scripts/checkpatch.pl should complain about it).

Quoted 8 lines
Quoted 5 lines

I just checked that even with an absurdly long subject (more than 200 characters), ./scripts/checkpatch.pl doesn't complain. It only complains when the commit message body has longer than 75 characters but not the subject line. What's the maximum subject line length?

People say 50 characters but that just seems more aspirational than realistic. This patch needs a subsystem prefix as well.

I fixed patch subj and applied to bpf tree.
Thanks everyone.