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: <1485443483.2980.1.camel@sandisk.com>
Date:   Thu, 26 Jan 2017 15:11:43 +0000
From:   Bart Van Assche <Bart.VanAssche@...disk.com>
To:     "augustocaringi@...il.com" <augustocaringi@...il.com>,
        "jejb@...ux.vnet.ibm.com" <jejb@...ux.vnet.ibm.com>
CC:     "linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
        "emilne@...hat.com" <emilne@...hat.com>,
        "andriy.shevchenko@...ux.intel.com" 
        <andriy.shevchenko@...ux.intel.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
        "sagi@...mberg.me" <sagi@...mberg.me>
Subject: Re: [PATCH] scsi: srp_transport: Fix 'always false comparison' in
 srp_tmo_valid()

On Thu, 2017-01-26 at 11:17 +0000, Augusto Mecking Caringi wrote:
> In a 64bit system (where long is 64bit wide), even dividing LONG_MAX by
> HZ will always be bigger than the max value that an int variable can
> hold.
> 
> This has been detected by building the driver with W=1:
> 
> drivers/scsi/scsi_transport_srp.c: In function ‘srp_tmo_valid’:
> drivers/scsi/scsi_transport_srp.c:92:19: warning: comparison is always
> false due to limited range of data type [-Wtype-limits]
> if (dev_loss_tmo >= LONG_MAX / HZ)
>                    ^
> 
> Signed-off-by: Augusto Mecking Caringi <augustocaringi@...il.com>
> ---
>  drivers/scsi/scsi_transport_srp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
> index b87a786..d8c83f4 100644
> --- a/drivers/scsi/scsi_transport_srp.c
> +++ b/drivers/scsi/scsi_transport_srp.c
> @@ -89,7 +89,7 @@ int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo, int dev_loss_tmo)
>  	if (fast_io_fail_tmo < 0 &&
>  	    dev_loss_tmo > SCSI_DEVICE_BLOCK_MAX_TIMEOUT)
>  		return -EINVAL;
> -	if (dev_loss_tmo >= LONG_MAX / HZ)
> +	if (dev_loss_tmo >= INT_MAX / HZ)
>  		return -EINVAL;
>  	if (fast_io_fail_tmo >= 0 && dev_loss_tmo >= 0 &&
>  	    fast_io_fail_tmo >= dev_loss_tmo)

This patch is wrong. The purpose of the dev_loss_tmo >= LONG_MAX / HZ check
is to avoid that the expression 1UL * dev_loss_tmo * HZ further down
overflows. Can you check whether changing the if-statement into if (1UL *
dev_loss_tmo >= LONG_MAX / HZ) also suppresses the compiler warning?

Bart.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ