From: KY Srinivasan <kys@microsoft.com>
To: Xiaohui Zhang <ruc_zhangxiaohui@163.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
Wei Liu <wei.liu@kernel.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [EXTERNAL] [PATCH 1/1] scsi: Fix possible buffer overflows in storvsc_queuecommand
Date: Tue, 8 Dec 2020 16:30:01 +0000 [thread overview]
Message-ID: <MW4PR21MB186053CCB0D774831A3B9501A0CD1@MW4PR21MB1860.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20201208131918.31534-1-ruc_zhangxiaohui@163.com>
> -----Original Message-----
> From: Xiaohui Zhang <ruc_zhangxiaohui@163.com>
> Sent: Tuesday, December 8, 2020 5:19 AM
> To: Xiaohui Zhang <ruc_zhangxiaohui@163.com>; KY Srinivasan
> <kys@microsoft.com>; Haiyang Zhang <haiyangz@microsoft.com>; Stephen
> Hemminger <sthemmin@microsoft.com>; Wei Liu <wei.liu@kernel.org>;
> James E.J. Bottomley <jejb@linux.ibm.com>; Martin K. Petersen
> <martin.petersen@oracle.com>; linux-hyperv@vger.kernel.org; linux-
> scsi@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [EXTERNAL] [PATCH 1/1] scsi: Fix possible buffer overflows in
> storvsc_queuecommand
>
> From: Zhang Xiaohui <ruc_zhangxiaohui@163.com>
>
> storvsc_queuecommand() calls memcpy() without checking the destination size
> may trigger a buffer overflower, which a local user could use to cause denial of
> service or the execution of arbitrary code.
> Fix it by putting the length check before calling memcpy().
>
> Signed-off-by: Zhang Xiaohui <ruc_zhangxiaohui@163.com>
> ---
> drivers/scsi/storvsc_drv.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index
> 0c65fbd41..09b60a4c0 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1729,6 +1729,8 @@ static int storvsc_queuecommand(struct Scsi_Host
> *host, struct scsi_cmnd *scmnd)
>
> vm_srb->cdb_length = scmnd->cmd_len;
>
> + if (vm_srb->cdb_length > STORVSC_MAX_CMD_LEN)
> + vm_srb->cdb_length = STORVSC_MAX_CMD_LEN;
> memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
The data structure is sized correctly to handle the max command length. Besides
your check is bogus - you cannot truncate the command!
K. Y
>
> sgl = (struct scatterlist *)scsi_sglist(scmnd);
> --
> 2.17.1
next prev parent reply other threads:[~2020-12-08 16:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-08 13:19 [PATCH 1/1] scsi: Fix possible buffer overflows in storvsc_queuecommand Xiaohui Zhang
2020-12-08 16:30 ` KY Srinivasan [this message]
2020-12-08 17:52 ` Michael Kelley
[not found] ` <56cde2c6.bb9.176451a57d7.Coremail.ruc_zhangxiaohui@163.com>
2020-12-09 13:31 ` Wei Liu
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=MW4PR21MB186053CCB0D774831A3B9501A0CD1@MW4PR21MB1860.namprd21.prod.outlook.com \
--to=kys@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=jejb@linux.ibm.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ruc_zhangxiaohui@163.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@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 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 NNTP newsgroup(s).