All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
@ 2020-11-11  5:03 xiakaixu1987
  2020-11-11  5:13 ` Andrii Nakryiko
  2020-11-11 10:07 ` Daniel Borkmann
  0 siblings, 2 replies; 4+ messages in thread
From: xiakaixu1987 @ 2020-11-11  5:03 UTC (permalink / raw)
  To: ast, daniel, kafai, songliubraving, yhs, andrii, john.fastabend, kpsingh
  Cc: netdev, bpf, linux-kernel, Kaixu Xia

From: Kaixu Xia <kaixuxia@tencent.com>

The unsigned variable datasec_id is assigned a return value from the call
to check_pseudo_btf_id(), which may return negative error code.

Fixes coccicheck warning:

./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
v3:
 -put the changes on the proper place.

v2:
 -split out datasec_id definition into a separate line.

 kernel/bpf/verifier.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 6200519582a6..6204ec705d80 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -9572,12 +9572,13 @@ static int check_pseudo_btf_id(struct bpf_verifier_env *env,
 			       struct bpf_insn *insn,
 			       struct bpf_insn_aux_data *aux)
 {
-	u32 datasec_id, type, id = insn->imm;
 	const struct btf_var_secinfo *vsi;
 	const struct btf_type *datasec;
 	const struct btf_type *t;
 	const char *sym_name;
 	bool percpu = false;
+	u32 type, id = insn->imm;
+	s32 datasec_id;
 	u64 addr;
 	int i;
 
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
  2020-11-11  5:03 [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id xiakaixu1987
@ 2020-11-11  5:13 ` Andrii Nakryiko
  2020-11-11  9:34   ` John Fastabend
  2020-11-11 10:07 ` Daniel Borkmann
  1 sibling, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2020-11-11  5:13 UTC (permalink / raw)
  To: xiakaixu1987
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, john fastabend, KP Singh,
	Networking, bpf, open list, Kaixu Xia

On Tue, Nov 10, 2020 at 9:03 PM <xiakaixu1987@gmail.com> wrote:
>
> From: Kaixu Xia <kaixuxia@tencent.com>
>
> The unsigned variable datasec_id is assigned a return value from the call
> to check_pseudo_btf_id(), which may return negative error code.
>
> Fixes coccicheck warning:
>
> ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0
>
> Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
> ---

Looks good.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

[...]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
  2020-11-11  5:13 ` Andrii Nakryiko
@ 2020-11-11  9:34   ` John Fastabend
  0 siblings, 0 replies; 4+ messages in thread
From: John Fastabend @ 2020-11-11  9:34 UTC (permalink / raw)
  To: Andrii Nakryiko, xiakaixu1987
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, john fastabend, KP Singh,
	Networking, bpf, open list, Kaixu Xia

Andrii Nakryiko wrote:
> On Tue, Nov 10, 2020 at 9:03 PM <xiakaixu1987@gmail.com> wrote:
> >
> > From: Kaixu Xia <kaixuxia@tencent.com>
> >
> > The unsigned variable datasec_id is assigned a return value from the call
> > to check_pseudo_btf_id(), which may return negative error code.
> >
> > Fixes coccicheck warning:
> >
> > ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0
> >
> > Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
> > Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
> > ---
> 
> Looks good.
> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> 
> [...]

Acked-by: John Fastabend <john.fastabend@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
  2020-11-11  5:03 [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id xiakaixu1987
  2020-11-11  5:13 ` Andrii Nakryiko
@ 2020-11-11 10:07 ` Daniel Borkmann
  1 sibling, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2020-11-11 10:07 UTC (permalink / raw)
  To: xiakaixu1987, ast, kafai, songliubraving, yhs, andrii,
	john.fastabend, kpsingh
  Cc: netdev, bpf, linux-kernel, Kaixu Xia

On 11/11/20 6:03 AM, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> The unsigned variable datasec_id is assigned a return value from the call
> to check_pseudo_btf_id(), which may return negative error code.
> 
> Fixes coccicheck warning:
> 
> ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0
> 
> Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>

Looks good, applied & also added Fixes tags, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-11 10:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11  5:03 [PATCH v3] bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id xiakaixu1987
2020-11-11  5:13 ` Andrii Nakryiko
2020-11-11  9:34   ` John Fastabend
2020-11-11 10:07 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.