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: <2a8c62e1-6e29-4ac6-b661-7b5ec1763288@acm.org>
Date: Wed, 19 Nov 2025 15:09:02 -0800
From: Bart Van Assche <bvanassche@....org>
To: david.laight.linux@...il.com, linux-kernel@...r.kernel.org,
 linux-scsi@...r.kernel.org
Cc: "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
 "Martin K. Petersen" <martin.petersen@...cle.com>
Subject: Re: [PATCH 26/44] drivers/scsi: use min() instead of min_t()

On 11/19/25 2:41 PM, david.laight.linux@...il.com wrote:
> From: David Laight <david.laight.linux@...il.com>
> 
> min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'.
> Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long'
> and so cannot discard significant bits.
> 
> In this case the 'unsigned long' value is small enough that the result
> is ok.
> 
> Detected by an extra check added to min_t().
> 
> Signed-off-by: David Laight <david.laight.linux@...il.com>
> ---
>   drivers/scsi/hosts.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index 17173239301e..b15896560cf6 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -247,7 +247,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
>   	shost->dma_dev = dma_dev;
>   
>   	if (dma_dev->dma_mask) {
> -		shost->max_sectors = min_t(unsigned int, shost->max_sectors,
> +		shost->max_sectors = min(shost->max_sectors,
>   				dma_max_mapping_size(dma_dev) >> SECTOR_SHIFT);
>   	}

So instead of the type cast performed by min_t() potentially discarding
bits, the assignment potentially discards bits. I'm not sure this is an
improvement.

Thanks,

Bart.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ