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: <e36f61af-4fbe-42cf-f26d-229f940e8fc9@canonical.com>
Date:   Tue, 29 Jun 2021 18:21:32 +0100
From:   Colin Ian King <colin.king@...onical.com>
To:     Daniel Bristot de Oliveira <bristot@...hat.com>,
        Steven Rostedt <rostedt@...dmis.org>
Cc:     kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org,
        Dan Carpenter <dan.carpenter@...cle.com>,
        Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH][next] trace: osnoise: Fix u64 less than zero comparison

On 29/06/2021 18:19, Daniel Bristot de Oliveira wrote:
> On 6/29/21 6:52 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@...onical.com>
>>
>> The less than zero comparison of the u64 variable 'noise' is always
>> false because the variable is unsigned. Since the time_sub macro
>> can potentially return an -ve vale, make the variable a s64 to
>> fix the issue.
> 
> Ops! concurrent bug fixing.

Well, shows static analysis is doing it's thing and I'm not being
vigilant enough by spotting that Dan found it earlier :-)

> 
> Dan Carpenter reported the same bug (and another problem), and I was working in
> the patches... I saw yours after sending his ones:
> 
> https://lore.kernel.org/lkml/acd7cd6e7d56b798a298c3bc8139a390b3c4ab52.1624986368.git.bristot@redhat.com/
> 
> The patches do the same fix, but there it also:
> 
>  - Made also max_noise s64 (it is snapshot of noise).
>  - Arranged the declarations in the inverted christmas tree.
> 
>> Addresses-Coverity: ("Unsigned compared against 0")
>> Fixes: bce29ac9ce0b ("trace: Add osnoise tracer")
>> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> 
> Steven, can we merge the flags?
> 
> -- Daniel
> 
>> ---
>>  kernel/trace/trace_osnoise.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
>> index 38aa5e208ffd..02c984560ceb 100644
>> --- a/kernel/trace/trace_osnoise.c
>> +++ b/kernel/trace/trace_osnoise.c
>> @@ -1040,11 +1040,11 @@ static void osnoise_stop_tracing(void)
>>  static int run_osnoise(void)
>>  {
>>  	struct osnoise_variables *osn_var = this_cpu_osn_var();
>> -	u64 noise = 0, sum_noise = 0, max_noise = 0;
>> +	u64 sum_noise = 0, max_noise = 0;
>>  	struct trace_array *tr = osnoise_trace;
>>  	u64 start, sample, last_sample;
>>  	u64 last_int_count, int_count;
>> -	s64 total, last_total = 0;
>> +	s64 noise = 0, total, last_total = 0;
>>  	struct osnoise_sample s;
>>  	unsigned int threshold;
>>  	int hw_count = 0;
>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ