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: <5355BEBA.8040001@gmail.com>
Date:	Tue, 22 Apr 2014 08:58:34 +0800
From:	Chen Gang <gang.chen.5i5j@...il.com>
To:	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	Pavel Machek <pavel@....cz>
CC:	Guan Xuetao <gxt@...c.pku.edu.cn>, len.brown@...el.com,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kernel/power/hibernate.c: be sure of 'start' is not bigger
 than 'stop'

On 04/22/2014 04:43 AM, Rafael J. Wysocki wrote:
> On Monday, April 21, 2014 10:09:30 PM Pavel Machek wrote:
>> On Mon 2014-04-21 21:40:27, Chen Gang wrote:
>>> For do_div(), it need 'u64' type, which means the outside must be sure
>>> of 'start' is not bigger than 'stop', or it will report warning.
>>>
>>> The related warning (with allmodconfig for unicore32):
>>>
>>>     CC      kernel/power/hibernate.o
>>>   kernel/power/hibernate.c: In function ‘swsusp_show_speed’:
>>>   kernel/power/hibernate.c:237: warning: comparison of distinct pointer types lacks a cast
>>>
>>> Signed-off-by: Chen Gang <gang.chen.5i5j@...il.com>
>>
>>>  {
>>> -	s64 elapsed_centisecs64;
>>> +	u64 elapsed_centisecs64;
>>>  	int centisecs;
>>>  	int k;
>>>  	int kps;
>>>  
>>>  	elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
>>> +	if ((s64)elapsed_centisecs64 < 0) {
>>> +		printk(KERN_ERR "PM: stop: %llu < start %llu\n",
>>> +			timeval_to_ns(stop), timeval_to_ns(start));
>>> +		return;
>>> +	}
>>>  	do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
>>>  	centisecs = elapsed_centisecs64;
>>>  	if (centisecs == 0)
>>
>> Quite a lot of code to shut up warning in mostly debugging
>> function... is there alternative method of shutting it up? Have you
>> seen < 0 values in wild?
> 
> No, I don't think so.  This is a purely theoretical problem that never
> happens in practice, because all of the callers do the right thing.
> 
> Rafael 
> 

OK, it sounds fine to me, I shall send patch v2 for it.

Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
--
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