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] [day] [month] [year] [list]
Message-ID: <473095f9-d04e-1f49-ea5b-f12329fbb435@wanadoo.fr>
Date:   Sat, 21 Aug 2021 07:40:51 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     jing yangyang <cgel.zte@...il.com>,
        Jason Wessel <jason.wessel@...driver.com>,
        Daniel Thompson <daniel.thompson@...aro.org>,
        Douglas Anderson <dianders@...omium.org>,
        Sumit Garg <sumit.garg@...aro.org>,
        Will Deacon <will@...nel.org>,
        Stephen Zhang <stephenzhangzsd@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        "Gustavo A . R . Silva" <gustavoars@...nel.org>,
        kgdb-bugreport@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Cc:     jing yangyang <jing.yangyang@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH linux-next] debug:kdb: fix unsigned int win compared to
 less than zero

Hi,

Le 20/08/2021 à 04:24, jing yangyang a écrit :
> Fix coccicheck warning:
> ./kernel/debug/kdb/kdb_support.c:575:3-10:
> WARNING:Unsigned expression compared with zero  p_state < 0
> 
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: jing yangyang <jing.yangyang@....com.cn>
> ---
>   kernel/debug/kdb/kdb_support.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
> index c605b17..fb30801 100644
> --- a/kernel/debug/kdb/kdb_support.c
> +++ b/kernel/debug/kdb/kdb_support.c
> @@ -560,7 +560,7 @@ unsigned long kdb_task_state_string(const char *s)
>    */
>   char kdb_task_state_char (const struct task_struct *p)
>   {
> -	unsigned int p_state;
> +	int p_state;

When you make changes in variables which are written in the reverse 
Christmas tree style (i.e. long lines at the top, shorter ones below), 
you should keep this style. Many people prefer it that way.

Also, should your fix be correct, it is likely a bugfix, and a "Fixes:" 
would be needed to help backport.


However, I don't think that your patch is correct here.

Unless I missed something, 'p_state' really needs to be an 'unsigned 
int' because 'p->__state' is an 'unsigned int' since 2f064a59a11f 
("sched: Change task_struct::state")

My *guess* is that:
		(p_state < 0) ? 'U' :
should be turned in:
		(p_state & UNRUNNABLE) ? 'U' :

to match the code in 'kdb_task_state_string(()'.

The 'R' case looks also spurious to me, but I've not looked at it deeper.


Should I be right, comment at line 545 ("/* unrunnable is < 0 */") looks 
somewhat misleading or useless. I would drop it.


Finally, you have the same kind of code in 'show_task()' 
(arch/powerpc/xmon/xmon.c). I also guess that whatever the fix it, it 
should be updated the same way here.

CJ

>   	unsigned long tmp;
>   	char state;
>   	int cpu;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ