All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
@ 2016-11-22 17:36 Cathy Avery
  2016-11-23  2:56   ` kbuild test robot
  2016-11-23  2:56   ` kbuild test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Cathy Avery @ 2016-11-22 17:36 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
could contain junk.

Suggested-by: Vitaly Kuznets <vkuznets@redhat.com>
Signed-off-by: Cathy Avery <cavery@redhat.com>
---
 drivers/scsi/storvsc_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 8ccfc9e..b4a8c9d 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1495,11 +1495,12 @@ 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);
 			if (!payload)
 				return SCSI_MLQUEUE_DEVICE_BUSY;
+			memset(payload, 0, payload_sz);
 		}
 
 		payload->range.len = length;
-- 
2.5.0

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

* Re: [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
  2016-11-22 17:36 [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
@ 2016-11-23  2:56   ` kbuild test robot
  2016-11-23  2:56   ` kbuild test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2016-11-23  2:56 UTC (permalink / raw)
  To: Cathy Avery
  Cc: kbuild-all, kys, haiyangz, jejb, martin.petersen, devel,
	linux-kernel, linux-scsi

Hi Cathy,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.9-rc6 next-20161122]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Cathy-Avery/storvsc-Payload-buffer-incorrectly-sized-for-32-bit-kernels/20161123-091420
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next


coccinelle warnings: (new ones prefixed by >>)

>> drivers/scsi/storvsc_drv.c:1500:13-20: WARNING: kzalloc should be used for payload, instead of kmalloc/memset

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

* [PATCH] storvsc: fix kzalloc-simple.cocci warnings
  2016-11-22 17:36 [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
@ 2016-11-23  2:56   ` kbuild test robot
  2016-11-23  2:56   ` kbuild test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2016-11-23  2:56 UTC (permalink / raw)
  To: Cathy Avery
  Cc: kbuild-all, kys, haiyangz, jejb, martin.petersen, devel,
	linux-kernel, linux-scsi

drivers/scsi/storvsc_drv.c:1500:13-20: WARNING: kzalloc should be used for payload, instead of kmalloc/memset


 Use kzalloc rather than kmalloc followed by memset with 0

 This considers some simple cases that are common and easy to validate
 Note in particular that there are no ...s in the rule, so all of the
 matched code has to be contiguous

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

CC: Cathy Avery <cavery@redhat.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 storvsc_drv.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1497,10 +1497,9 @@ static int storvsc_queuecommand(struct S
 
 			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;
-			memset(payload, 0, payload_sz);
 		}
 
 		payload->range.len = length;

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

* [PATCH] storvsc: fix kzalloc-simple.cocci warnings
@ 2016-11-23  2:56   ` kbuild test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2016-11-23  2:56 UTC (permalink / raw)
  To: Cathy Avery
  Cc: jejb, linux-scsi, martin.petersen, haiyangz, linux-kernel,
	kbuild-all, devel

drivers/scsi/storvsc_drv.c:1500:13-20: WARNING: kzalloc should be used for payload, instead of kmalloc/memset


 Use kzalloc rather than kmalloc followed by memset with 0

 This considers some simple cases that are common and easy to validate
 Note in particular that there are no ...s in the rule, so all of the
 matched code has to be contiguous

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

CC: Cathy Avery <cavery@redhat.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 storvsc_drv.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1497,10 +1497,9 @@ static int storvsc_queuecommand(struct S
 
 			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;
-			memset(payload, 0, payload_sz);
 		}
 
 		payload->range.len = length;

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

* Re: [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels.
@ 2016-11-23  2:56   ` kbuild test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2016-11-23  2:56 UTC (permalink / raw)
  To: Cathy Avery
  Cc: jejb, linux-scsi, martin.petersen, haiyangz, linux-kernel,
	kbuild-all, devel

Hi Cathy,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.9-rc6 next-20161122]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Cathy-Avery/storvsc-Payload-buffer-incorrectly-sized-for-32-bit-kernels/20161123-091420
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next


coccinelle warnings: (new ones prefixed by >>)

>> drivers/scsi/storvsc_drv.c:1500:13-20: WARNING: kzalloc should be used for payload, instead of kmalloc/memset

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

end of thread, other threads:[~2016-11-23  2:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-22 17:36 [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels Cathy Avery
2016-11-23  2:56 ` [PATCH] storvsc: fix kzalloc-simple.cocci warnings kbuild test robot
2016-11-23  2:56   ` kbuild test robot
2016-11-23  2:56 ` [PATCH] [hv] storvsc: Payload buffer incorrectly sized for 32 bit kernels kbuild test robot
2016-11-23  2:56   ` kbuild test robot

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.