LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
@ 2016-11-23 13:46 Cathy Avery
  2016-11-29 16:57 ` Martin K. Petersen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Cathy Avery @ 2016-11-23 13:46 UTC (permalink / raw
  To: kys, haiyangz, jejb, martin.petersen; +Cc: devel, linux-kernel, linux-scsi

On a 32 bit kernel sizeof(void *) is not 64 bits as hv_mpb_array
requires. Also the buffer needs to be cleared or the upper bytes
will contain junk.

Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Cathy Avery <cavery@redhat.com>

ChangeLog:

v1) Initial submission
v2) Remove memset and replace kmalloc with kzalloc.
---
 drivers/scsi/storvsc_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 8ccfc9e..05526b7 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1495,9 +1495,9 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
 	if (sg_count) {
 		if (sg_count > MAX_PAGE_BUFFER_COUNT) {
 
-			payload_sz = (sg_count * sizeof(void *) +
+			payload_sz = (sg_count * sizeof(u64) +
 				      sizeof(struct vmbus_packet_mpb_array));
-			payload = kmalloc(payload_sz, GFP_ATOMIC);
+			payload = kzalloc(payload_sz, GFP_ATOMIC);
 			if (!payload)
 				return SCSI_MLQUEUE_DEVICE_BUSY;
 		}
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
  2016-11-23 13:46 [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
@ 2016-11-29 16:57 ` Martin K. Petersen
  2016-11-30  6:17   ` KY Srinivasan
  2016-11-30  6:14 ` KY Srinivasan
  2016-11-30 16:39 ` Martin K. Petersen
  2 siblings, 1 reply; 6+ messages in thread
From: Martin K. Petersen @ 2016-11-29 16:57 UTC (permalink / raw
  To: Cathy Avery
  Cc: kys, haiyangz, jejb, martin.petersen, devel, linux-kernel,
	linux-scsi

>>>>> "Cathy" == Cathy Avery <cavery@redhat.com> writes:

Cathy> On a 32 bit kernel sizeof(void *) is not 64 bits as hv_mpb_array
Cathy> requires. Also the buffer needs to be cleared or the upper bytes
Cathy> will contain junk.

K.Y.: Please review!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
  2016-11-23 13:46 [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
  2016-11-29 16:57 ` Martin K. Petersen
@ 2016-11-30  6:14 ` KY Srinivasan
  2016-11-30 16:39 ` Martin K. Petersen
  2 siblings, 0 replies; 6+ messages in thread
From: KY Srinivasan @ 2016-11-30  6:14 UTC (permalink / raw
  To: Cathy Avery, Haiyang Zhang, jejb@linux.vnet.ibm.com,
	martin.petersen@oracle.com
  Cc: devel@linuxdriverproject.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org



> -----Original Message-----
> From: Cathy Avery [mailto:cavery@redhat.com]
> Sent: Wednesday, November 23, 2016 5:47 AM
> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; jejb@linux.vnet.ibm.com;
> martin.petersen@oracle.com
> Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; linux-
> scsi@vger.kernel.org
> Subject: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit
> kernels.
> 
> On a 32 bit kernel sizeof(void *) is not 64 bits as hv_mpb_array
> requires. Also the buffer needs to be cleared or the upper bytes
> will contain junk.
> 
> Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Signed-off-by: Cathy Avery <cavery@redhat.com>

Thanks Cathy.

Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> 
> ChangeLog:
> 
> v1) Initial submission
> v2) Remove memset and replace kmalloc with kzalloc.
> ---
>  drivers/scsi/storvsc_drv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 8ccfc9e..05526b7 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1495,9 +1495,9 @@ static int storvsc_queuecommand(struct Scsi_Host
> *host, struct scsi_cmnd *scmnd)
>  	if (sg_count) {
>  		if (sg_count > MAX_PAGE_BUFFER_COUNT) {
> 
> -			payload_sz = (sg_count * sizeof(void *) +
> +			payload_sz = (sg_count * sizeof(u64) +
>  				      sizeof(struct vmbus_packet_mpb_array));
> -			payload = kmalloc(payload_sz, GFP_ATOMIC);
> +			payload = kzalloc(payload_sz, GFP_ATOMIC);
>  			if (!payload)
>  				return SCSI_MLQUEUE_DEVICE_BUSY;
>  		}
> --
> 2.5.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
  2016-11-29 16:57 ` Martin K. Petersen
@ 2016-11-30  6:17   ` KY Srinivasan
  2016-11-30 16:39     ` Martin K. Petersen
  0 siblings, 1 reply; 6+ messages in thread
From: KY Srinivasan @ 2016-11-30  6:17 UTC (permalink / raw
  To: Martin K. Petersen, Cathy Avery
  Cc: Haiyang Zhang, jejb@linux.vnet.ibm.com,
	devel@linuxdriverproject.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org



> -----Original Message-----
> From: Martin K. Petersen [mailto:martin.petersen@oracle.com]
> Sent: Tuesday, November 29, 2016 8:58 AM
> To: Cathy Avery <cavery@redhat.com>
> Cc: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; jejb@linux.vnet.ibm.com;
> martin.petersen@oracle.com; devel@linuxdriverproject.org; linux-
> kernel@vger.kernel.org; linux-scsi@vger.kernel.org
> Subject: Re: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32
> bit kernels.
> 
> >>>>> "Cathy" == Cathy Avery <cavery@redhat.com> writes:
> 
> Cathy> On a 32 bit kernel sizeof(void *) is not 64 bits as hv_mpb_array
> Cathy> requires. Also the buffer needs to be cleared or the upper bytes
> Cathy> will contain junk.
> 
> K.Y.: Please review!

Done.

K. Y
> 
> --
> Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
  2016-11-23 13:46 [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
  2016-11-29 16:57 ` Martin K. Petersen
  2016-11-30  6:14 ` KY Srinivasan
@ 2016-11-30 16:39 ` Martin K. Petersen
  2 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2016-11-30 16:39 UTC (permalink / raw
  To: Cathy Avery
  Cc: kys, haiyangz, jejb, martin.petersen, devel, linux-kernel,
	linux-scsi

>>>>> "Cathy" == Cathy Avery <cavery@redhat.com> writes:

Cathy> On a 32 bit kernel sizeof(void *) is not 64 bits as hv_mpb_array
Cathy> requires. Also the buffer needs to be cleared or the upper bytes
Cathy> will contain junk.

Applied to 4.10/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
  2016-11-30  6:17   ` KY Srinivasan
@ 2016-11-30 16:39     ` Martin K. Petersen
  0 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2016-11-30 16:39 UTC (permalink / raw
  To: KY Srinivasan
  Cc: Martin K. Petersen, Cathy Avery, Haiyang Zhang,
	jejb@linux.vnet.ibm.com, devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org

>>>>> "KY" == KY Srinivasan <kys@microsoft.com> writes:

KY> Done.

Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-30 16:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-23 13:46 [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
2016-11-29 16:57 ` Martin K. Petersen
2016-11-30  6:17   ` KY Srinivasan
2016-11-30 16:39     ` Martin K. Petersen
2016-11-30  6:14 ` KY Srinivasan
2016-11-30 16:39 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).