bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
Subsystems (4)
PATCH v3 1/1 bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
From: Kaixu Xia <[email protected]>
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
---
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(-)
kernel/bpf/verifier.c +2 -1
@@ -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;
Signature · 1 line
2.20.0
Quoted 6 lines · On Tue, Nov 10, 2020 at 9:03 PM <[email protected]> wrote:
From: Kaixu Xia <[email protected]>
The unsigned variable
datasec_idis assigned a return value from the call tocheck_pseudo_btf_id(), which may return negative error code.
Quoted 7 lines
Fixes coccicheck warning:
./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero:
datasec_id> 0Reported-by Tosk Robot <[email protected]>Signed-off-by Kaixu Xia <[email protected]>---
Looks good.
[...]
Quoted 15 lines · Andrii Nakryiko
Quoted 6 lines · On Tue, Nov 10, 2020 at 9:03 PM <[email protected]> wrote:
From: Kaixu Xia <[email protected]>
The unsigned variable
datasec_idis assigned a return value from the call tocheck_pseudo_btf_id(), which may return negative error code.Quoted 7 lines
Fixes coccicheck warning:
./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero:
datasec_id> 0Reported-by Tosk Robot <[email protected]>Signed-off-by Kaixu Xia <[email protected]>---
Quoted 5 lines
Looks good.
Acked-by Andrii Nakryiko <[email protected]>[...]
Daniel Borkmann
maintainerQuoted 11 lines · On 11/11/20 6:03 AM, [email protected] wrote:
From: Kaixu Xia <[email protected]>
The unsigned variable
datasec_idis assigned a return value from the call tocheck_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> 0Reported-by Tosk Robot <[email protected]>Signed-off-by Kaixu Xia <[email protected]>
Looks good, applied & also added Fixes tags, thanks!