Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1637056 > unrolled thread

RE: [PATCH] char: random: casting prevents missing calculations

Started byKarim Eshapa <karim.eshapa@gmail.com>
First post2017-05-08 00:00 +0200
Last post2017-05-08 00:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  RE: [PATCH] char: random: casting prevents missing calculations Karim Eshapa <karim.eshapa@gmail.com> - 2017-05-08 00:00 +0200

#1637056 — RE: [PATCH] char: random: casting prevents missing calculations

FromKarim Eshapa <karim.eshapa@gmail.com>
Date2017-05-08 00:00 +0200
SubjectRE: [PATCH] char: random: casting prevents missing calculations
Message-ID<tECdY-30b-9@gated-at.bofh.it>
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@gmail.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@gmail.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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web