From: Bart Van Assche <bart.vanassche@sandisk.com>
To: mchristi@redhat.com, linux-scsi@vger.kernel.org,
target-devel@vger.kernel.org, socketpair@gmail.com
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 1/2] scsi: fix max discard sectors calculation
Date: Mon, 16 May 2016 15:44:48 -0700 [thread overview]
Message-ID: <573A4D60.7080902@sandisk.com> (raw)
In-Reply-To: <1463424410-17196-2-git-send-email-mchristi@redhat.com>
On 05/16/2016 11:46 AM, mchristi@redhat.com wrote:
> logical_block_size and max_blocks are 32 bits, so we can
> overflow when trying to convert SCSI device blocks to linux
> block layer sectors.
>
> Signed-off-by: Mike Christie <mchristi@redhat.com>
> Cc: stable@vger.kernel.org
>
> ---
> drivers/scsi/sd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index f52b74c..1668e1d 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -690,7 +690,8 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
> - blk_queue_max_discard_sectors(q, max_blocks * (logical_block_size >> 9));
> + blk_queue_max_discard_sectors(q, (u64)max_blocks *
> + (logical_block_size >> 9));
Hello Mike,
As far as I can see max_blocks <= 0xffff (SD_MAX_WS10_BLOCKS) and 512 <=
logical_block_size <= 4096. How can max_blocks * (logical_block_size >>
9) be too large for a 32 bit integer?
Thanks,
Bart.
WARNING: multiple messages have this Message-ID (diff)
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: <mchristi@redhat.com>, <linux-scsi@vger.kernel.org>,
<target-devel@vger.kernel.org>, <socketpair@gmail.com>
Cc: <stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] scsi: fix max discard sectors calculation
Date: Mon, 16 May 2016 15:44:48 -0700 [thread overview]
Message-ID: <573A4D60.7080902@sandisk.com> (raw)
In-Reply-To: <1463424410-17196-2-git-send-email-mchristi@redhat.com>
On 05/16/2016 11:46 AM, mchristi@redhat.com wrote:
> logical_block_size and max_blocks are 32 bits, so we can
> overflow when trying to convert SCSI device blocks to linux
> block layer sectors.
>
> Signed-off-by: Mike Christie <mchristi@redhat.com>
> Cc: stable@vger.kernel.org
>
> ---
> drivers/scsi/sd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index f52b74c..1668e1d 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -690,7 +690,8 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
> - blk_queue_max_discard_sectors(q, max_blocks * (logical_block_size >> 9));
> + blk_queue_max_discard_sectors(q, (u64)max_blocks *
> + (logical_block_size >> 9));
Hello Mike,
As far as I can see max_blocks <= 0xffff (SD_MAX_WS10_BLOCKS) and 512 <=
logical_block_size <= 4096. How can max_blocks * (logical_block_size >>
9) be too large for a 32 bit integer?
Thanks,
Bart.
next prev parent reply other threads:[~2016-05-16 22:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-16 18:46 [PATCH 0/2] fix max discard sectors calculation mchristi
2016-05-16 18:46 ` [PATCH 1/2] scsi: " mchristi
2016-05-16 22:44 ` Bart Van Assche [this message]
2016-05-16 22:44 ` Bart Van Assche
2016-05-17 3:46 ` Mike Christie
2016-05-16 18:46 ` [PATCH 2/2] target: " mchristi
2016-05-16 18:57 ` Bart Van Assche
2016-05-16 18:57 ` Bart Van Assche
2016-05-16 19:00 ` Mike Christie
2016-05-16 19:02 ` Martin K. Petersen
2016-05-16 19:02 ` Martin K. Petersen
2016-05-17 18:16 ` Bart Van Assche
2016-05-17 18:16 ` Bart Van Assche
2016-05-17 21:49 ` Mike Christie
2016-05-18 16:56 ` Bart Van Assche
2016-05-18 16:56 ` Bart Van Assche
2016-05-18 17:17 ` Mike Christie
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=573A4D60.7080902@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mchristi@redhat.com \
--cc=socketpair@gmail.com \
--cc=stable@vger.kernel.org \
--cc=target-devel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.