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: <20090524194255.GD1337@ucw.cz>
Date:	Sun, 24 May 2009 21:42:55 +0200
From:	Pavel Machek <pavel@....cz>
To:	Subrata Modak <subrata@...ux.vnet.ibm.com>
Cc:	x86@...nel.org, Sachin P Sant <sachinp@...ux.vnet.ibm.com>,
	"H. Peter Anvin" <hpa@...or.com>, Andi Kleen <andi@...stfloor.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...hat.com>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>
Subject: Re: [PATCH] Remove indirect variable usage at arch/x86/kernel/tsc.c

Hi!

> CC      arch/x86/kernel/tsc.o
> arch/x86/kernel/tsc.c: In function 'time_cpufreq_notifier':
> arch/x86/kernel/tsc.c:634: warning: 'dummy' may be used uninitialized in this function
> 
> However, there seems to be no practical usage of variable 'dummy'
> in the following piece of code:
> 
> 630 static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
> 631                                 void *data)
> 632 {
> 633         struct cpufreq_freqs *freq = data;
> 634         unsigned long *lpj, dummy;
> 635 
> 636         if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
> 637                 return 0;
> 638 
> 639         lpj = &dummy;
> 640         if (!(freq->flags & CPUFREQ_CONST_LOOPS))
> 641 #ifdef CONFIG_SMP
> 642                 lpj = &cpu_data(freq->cpu).loops_per_jiffy;
> 643 #else
> 644         lpj = &boot_cpu_data.loops_per_jiffy;
> 645 #endif
> 646 
> 
> 'lpj' probably will get to point to some address after this if() statement.
> 
> 647         if (!ref_freq) {
> 648                 ref_freq = freq->old;
> 649                 loops_per_jiffy_ref = *lpj;
> 
> And, if it does, then "loops_per_jiffy_ref" will have a proper value,
> else, even with "lpj = &dummy" will not gurantee "loops_per_jiffy_ref = *lpj"
> to have the expected value.

But that's a bug to be fixed, I'd say? ... actually I believe you are
introducing a bug here. Yes, old code would put random numbers in
loops_per_jiffy_ref for !CPUFREQ_CONST_LOOPS, but you are introducing
oops there.

Have you tested the code?

> @@ -631,12 +631,11 @@ static int time_cpufreq_notifier(struct 
>  				void *data)
>  {
>  	struct cpufreq_freqs *freq = data;
> -	unsigned long *lpj, dummy;
> +	unsigned long *lpj = NULL;
>  
>  	if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
>  		return 0;
>  
> -	lpj = &dummy;
>  	if (!(freq->flags & CPUFREQ_CONST_LOOPS))
>  #ifdef CONFIG_SMP
>  		lpj = &cpu_data(freq->cpu).loops_per_jiffy;
> 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ