lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 24 Jun 2024 13:16:00 -0700
From: Eduard Zingerman <eddyz87@...il.com>
To: Thorsten Blum <thorsten.blum@...lux.com>, martin.lau@...ux.dev, 
 ast@...nel.org, daniel@...earbox.net, andrii@...nel.org, song@...nel.org, 
 john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me,
 haoluo@...gle.com,  jolsa@...nel.org, yonghong.song@...ux.dev,
 bpf@...r.kernel.org,  linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bpf, btf: Make if test explicit to fix Coccinelle error

On Mon, 2024-06-24 at 21:54 +0200, Thorsten Blum wrote:
> Explicitly test the iterator variable i > 0 to fix the following
> Coccinelle/coccicheck error reported by itnull.cocci:
> 
> 	ERROR: iterator variable bound on line 4688 cannot be NULL
> 
> Compile-tested only.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
>  kernel/bpf/btf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 821063660d9f..7720f8967814 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -4687,7 +4687,7 @@ static void btf_datasec_show(const struct btf *btf,
>  			    __btf_name_by_offset(btf, t->name_off));
>  	for_each_vsi(i, t, vsi) {
>  		var = btf_type_by_id(btf, vsi->type);
> -		if (i)
> +		if (i > 0)
>  			btf_show(show, ",");
>  		btf_type_ops(var)->show(btf, var, vsi->type,
>  					data + vsi->offset, bits_offset, show);

Could you please elaborate a bit?
Here is for_each_vsi is defined:

#define for_each_vsi(i, datasec_type, member)			\
	for (i = 0, member = btf_type_var_secinfo(datasec_type);	\
	     i < btf_type_vlen(datasec_type);			\
	     i++, member++)

Here it sets 'i' to zero for the first iteration.
Why would the tool report that 'i' can't be zero?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ