Re: [PATCH] [SCSI] megaraid_sas: Sanity check user supplied length before passing it to dma_alloc_coherent()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 19 Jan 2011 07:33:56 +0100
**UNKNOWN CHARSET** <bjorn@xxxxxxx> wrote:

> Both users have confirmed that the patch fixes their problem. One could
> of course imagine a workaround in the smartctl application so that it
> never sent requests with a zero iov_len, but I still believe that
> actually fixing the driver to handle such requests is better.

The patch looks fine to me. dma_alloc_coherent() doesn't take zero for
the size argument (causes a kernel crash). The driver can't assume
that an applications is sane so it needs to check the size that an
application passed on.

Unfortunately, your patch can't be applied to the latest git. I think
that you need to submit the updated patch first. After it's merged,
you can send stable maintainers the modified patch that can be applied
to stable kernels.

Btw, about your patch, it's better to use "if (!hoge)" instead of "if
(hoge == 0)" and kbuff_arr[] is initialized so seems that you don't
need to reset it again. The updated patch would be something like:

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 5d6d07b..cee1d3b 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4611,6 +4611,9 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
 	 * For each user buffer, create a mirror buffer and copy in
 	 */
 	for (i = 0; i < ioc->sge_count; i++) {
+		if (!ioc->sgl[i].iov_len)
+			continue;
+
 		kbuff_arr[i] = dma_alloc_coherent(&instance->pdev->dev,
 						    ioc->sgl[i].iov_len,
 						    &buf_handle, GFP_KERNEL);
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux