[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1494187086-4529-1-git-send-email-karim.eshapa@gmail.com>
Date: Sun, 7 May 2017 21:58:06 +0200
From: Karim Eshapa <karim.eshapa@...il.com>
To: tytso@....edu
Cc: arnd@...db.de, gregkh@...uxfoundation.org,
linux-kernel@...r.kernel.org, Karim Eshapa <karim.eshapa@...il.com>
Subject: RE: [PATCH] char: random: casting prevents missing calculations
On Sun, 7 May 2017 20:36:55 +0200, Arnd Bergmann wrote:
>On Sun, May 7, 2017 at 2:47 PM, Karim Eshapa <karim.eshapa@...il.com> wrote:
>> Cast (long)jiffies and (long)state->last_time beacause
>> they tends to unsigned long. may cause a problem specially
>> when comparison happens (< 0).
>>
>> Signed-off-by: Karim Eshapa <karim.eshapa@...il.com>
>>
>I don't understand what you are saying above, and the patch does not
>appear to have any effect since the destination variable is already of
>type 'long'.
>
>What problem did you observe?
>
I mean if jiffies = 0xf0000000 and
state->last_time was = 0x70000000 then
sample.jiffies = jiffies; here you assign signed long with
unsigned with last bit = 1
..
...
if (!state->dont_count_entropy) {
delta = sample.jiffies - state->last_time;
state->last_time = sample.jiffies;
...
...
if (delta < 0)
so, here this condition will be
true while it has to be false.
}
So, I think that may cause a problem.
Thanks,
Karim
Powered by blists - more mailing lists