From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756088AbdEGVw4 (ORCPT ); Sun, 7 May 2017 17:52:56 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36164 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751915AbdEGVwy (ORCPT ); Sun, 7 May 2017 17:52:54 -0400 From: Karim Eshapa To: tytso@mit.edu Cc: arnd@arndb.de, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, Karim Eshapa Subject: RE: [PATCH] char: random: casting prevents missing calculations Date: Sun, 7 May 2017 21:58:06 +0200 Message-Id: <1494187086-4529-1-git-send-email-karim.eshapa@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494161245-5722-1-git-send-email-karim.eshapa@gmail.com> References: <1494161245-5722-1-git-send-email-karim.eshapa@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 7 May 2017 20:36:55 +0200, Arnd Bergmann wrote: >On Sun, May 7, 2017 at 2:47 PM, Karim Eshapa 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 >> >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