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]
Message-ID: <20200330143540.GQ20696@hirez.programming.kicks-ass.net>
Date:   Mon, 30 Mar 2020 16:35:40 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Borislav Petkov <bp@...e.de>
Cc:     x86-ml <x86@...nel.org>, lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] sched/vtime: Fix an unitialized variable warning

On Fri, Mar 27, 2020 at 10:43:34PM +0100, Borislav Petkov wrote:
> Hi dude,
> 
> right before I was going to send the trivial, shut-up-gcc variant, I
> thought that maybe we should do this instead.
> 
> Thoughts?
> 
> ---
> Fix:
> 
>   kernel/sched/cputime.c: In function ‘kcpustat_field’:
>   kernel/sched/cputime.c:1007:6: warning: ‘val’ may be used \
> 	  uninitialized in this function [-Wmaybe-uninitialized]
>    1007 |  u64 val;
>         | ^~~
> 
> because gcc can't see that val is used only when err is 0.
> 
> Signed-off-by: Borislav Petkov <bp@...e.de>
> ---
>  kernel/sched/cputime.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index dac9104d126f..ff9435dee1df 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -1003,12 +1003,12 @@ u64 kcpustat_field(struct kernel_cpustat *kcpustat,
>  		   enum cpu_usage_stat usage, int cpu)
>  {
>  	u64 *cpustat = kcpustat->cpustat;
> +	u64 val = cpustat[usage];
>  	struct rq *rq;
> -	u64 val;
>  	int err;
>  
>  	if (!vtime_accounting_enabled_cpu(cpu))
> -		return cpustat[usage];
> +		return val;
>  
>  	rq = cpu_rq(cpu);


Hurph.. this might result in an unconditional load (and extra
cache-miss) for the vtime_accounting_enabled_cpu() case.

I suspesct the =0 this would be better. Stupid stupid compiler!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ