Skip to contentSkip to conversation

storvsc: Payload buffer incorrectly sized for 32 bit kernels.

PATCH Applied Cathy Avery 3 participants 6 messages Nov 23, 2016 – Nov 30, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

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(-)
drivers/scsi/storvsc_drv.c +2 -2
index 8ccfc9e..05526b7 100644
@@ -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;
 		}
Signature · 1 line
2.5.0
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cathy" == Cathy Avery <[email protected]> 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!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
Reviewed-by on v2 1/1
#4 lore raw
In reply to Cathy Avery
Quoted 13 lines

-----Original Message-----
From: Cathy Avery [mailto:[email protected]]
Sent: Wednesday, November 23, 2016 5:47 AM
To: KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.

Quoted 6 lines

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.

Thanks Cathy.

Quoted 28 lines

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(-)
drivers/scsi/storvsc_drv.c +2 -2
index 8ccfc9e..05526b7 100644
@@ -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

#2 lore raw
In reply to Martin K. Petersen
Quoted 13 lines

-----Original Message-----
From: Martin K. Petersen [mailto:[email protected]]
Sent: Tuesday, November 29, 2016 8:58 AM
To: Cathy Avery <[email protected]>
Cc: KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH v2] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cathy" == Cathy Avery <[email protected]> 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

Quoted 3 lines

--
Martin K. Petersen Oracle Linux Engineering

#5 lore raw
In reply to Cathy Avery
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Cathy" == Cathy Avery <[email protected]> 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.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering