mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karim Eshapa <karim.eshapa@gmail.com>
To: tytso@mit.edu
Cc: arnd@arndb.de, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org,
	Karim Eshapa <karim.eshapa@gmail.com>
Subject: RE: [PATCH] char: random: casting prevents missing calculations
Date: Sun,  7 May 2017 21:58:06 +0200	[thread overview]
Message-ID: <1494187086-4529-1-git-send-email-karim.eshapa@gmail.com> (raw)
In-Reply-To: <1494161245-5722-1-git-send-email-karim.eshapa@gmail.com>

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

  parent reply	other threads:[~2017-05-07 21:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 12:47 Karim Eshapa
2017-05-07 18:36 ` Arnd Bergmann
2017-05-07 19:58 ` Karim Eshapa [this message]
2017-05-07 21:34   ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494187086-4529-1-git-send-email-karim.eshapa@gmail.com \
    --to=karim.eshapa@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®