* [PATCH] scsi: zero per-cmd driver data for each MQ I/O
@ 2017-05-10 21:07 Long Li
2017-05-15 22:48 ` Long Li
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Long Li @ 2017-05-10 21:07 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel; +Cc: Long Li
From: Long Li <longli@microsoft.com>
Lower layer driver may not initialize private data before use. Zero them
out to prevent use of stale data.
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/scsi/scsi_lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 19125d7..a821593 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1850,7 +1850,7 @@ static int scsi_mq_prep_fn(struct request *req)
/* zero out the cmd, except for the embedded scsi_request */
memset((char *)cmd + sizeof(cmd->req), 0,
- sizeof(*cmd) - sizeof(cmd->req));
+ sizeof(*cmd) - sizeof(cmd->req) + shost->hostt->cmd_size);
req->special = cmd;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
2017-05-10 21:07 [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li
@ 2017-05-15 22:48 ` Long Li
2017-05-15 23:20 ` KY Srinivasan
2017-05-15 23:02 ` [Possible Phish Fraud][PATCH] " Bart Van Assche
2017-05-18 6:55 ` [PATCH] " Christoph Hellwig
2 siblings, 1 reply; 5+ messages in thread
From: Long Li @ 2017-05-15 22:48 UTC (permalink / raw)
To: Long Li, James E.J. Bottomley, Martin K. Petersen,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: KY Srinivasan, Stephen Hemminger
> -----Original Message-----
> From: Long Li [mailto:longli@exchange.microsoft.com]
> Sent: Wednesday, May 10, 2017 2:07 PM
> To: James E.J. Bottomley <jejb@linux.vnet.ibm.com>; Martin K. Petersen
> <martin.petersen@oracle.com>; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Long Li <longli@microsoft.com>
> Subject: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
>
> From: Long Li <longli@microsoft.com>
>
> Lower layer driver may not initialize private data before use. Zero them out
> to prevent use of stale data.
>
> Signed-off-by: Long Li <longli@microsoft.com>
Can someone help review this patch?
> ---
> drivers/scsi/scsi_lib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index
> 19125d7..a821593 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1850,7 +1850,7 @@ static int scsi_mq_prep_fn(struct request *req)
>
> /* zero out the cmd, except for the embedded scsi_request */
> memset((char *)cmd + sizeof(cmd->req), 0,
> - sizeof(*cmd) - sizeof(cmd->req));
> + sizeof(*cmd) - sizeof(cmd->req) +
> + shost->hostt->cmd_size);
>
> req->special = cmd;
>
> --
> 2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Possible Phish Fraud][PATCH] scsi: zero per-cmd driver data for each MQ I/O
2017-05-10 21:07 [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li
2017-05-15 22:48 ` Long Li
@ 2017-05-15 23:02 ` Bart Van Assche
2017-05-18 6:55 ` [PATCH] " Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2017-05-15 23:02 UTC (permalink / raw)
To: jejb@linux.vnet.ibm.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, longli@exchange.microsoft.com,
martin.petersen@oracle.com
Cc: longli@microsoft.com
On Wed, 2017-05-10 at 14:07 -0700, Long Li wrote:
> From: Long Li <longli@microsoft.com>
>
> Lower layer driver may not initialize private data before use. Zero them
> out to prevent use of stale data.
>
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
> drivers/scsi/scsi_lib.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 19125d7..a821593 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1850,7 +1850,7 @@ static int scsi_mq_prep_fn(struct request *req)
>
> /* zero out the cmd, except for the embedded scsi_request */
> memset((char *)cmd + sizeof(cmd->req), 0,
> - sizeof(*cmd) - sizeof(cmd->req));
> + sizeof(*cmd) - sizeof(cmd->req) + shost->hostt->cmd_size);
>
> req->special = cmd;
Hello Long,
Sorry but this patch looks wrong to me. Since scsi_mq_prep_fn() is called
after scsi_req_init(), erasing struct scsi_request from scsi_mq_prep_fn()
will erase the values that were set by scsi_req_init(). That includes
information like the pointer to the SCSI CDB and the CDB itself. See e.g.
scsi_execute().
Did you come up with this patch after source reading or did you come up
with this patch while chasing a bug?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
2017-05-15 22:48 ` Long Li
@ 2017-05-15 23:20 ` KY Srinivasan
0 siblings, 0 replies; 5+ messages in thread
From: KY Srinivasan @ 2017-05-15 23:20 UTC (permalink / raw)
To: Long Li, James E.J. Bottomley, Martin K. Petersen,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Stephen Hemminger
> -----Original Message-----
> From: Long Li
> Sent: Monday, May 15, 2017 3:48 PM
> To: Long Li <longli@microsoft.com>; James E.J. Bottomley
> <jejb@linux.vnet.ibm.com>; Martin K. Petersen
> <martin.petersen@oracle.com>; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: KY Srinivasan <kys@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>
> Subject: RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
>
> > -----Original Message-----
> > From: Long Li [mailto:longli@exchange.microsoft.com]
> > Sent: Wednesday, May 10, 2017 2:07 PM
> > To: James E.J. Bottomley <jejb@linux.vnet.ibm.com>; Martin K. Petersen
> > <martin.petersen@oracle.com>; linux-scsi@vger.kernel.org; linux-
> > kernel@vger.kernel.org
> > Cc: Long Li <longli@microsoft.com>
> > Subject: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
> >
> > From: Long Li <longli@microsoft.com>
> >
> > Lower layer driver may not initialize private data before use. Zero them out
> > to prevent use of stale data.
> >
> > Signed-off-by: Long Li <longli@microsoft.com>
>
> Can someone help review this patch?
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
>
> > ---
> > drivers/scsi/scsi_lib.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index
> > 19125d7..a821593 100644
> > --- a/drivers/scsi/scsi_lib.c
> > +++ b/drivers/scsi/scsi_lib.c
> > @@ -1850,7 +1850,7 @@ static int scsi_mq_prep_fn(struct request *req)
> >
> > /* zero out the cmd, except for the embedded scsi_request */
> > memset((char *)cmd + sizeof(cmd->req), 0,
> > - sizeof(*cmd) - sizeof(cmd->req));
> > + sizeof(*cmd) - sizeof(cmd->req) +
> > + shost->hostt->cmd_size);
> >
> > req->special = cmd;
> >
> > --
> > 2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
2017-05-10 21:07 [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li
2017-05-15 22:48 ` Long Li
2017-05-15 23:02 ` [Possible Phish Fraud][PATCH] " Bart Van Assche
@ 2017-05-18 6:55 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-05-18 6:55 UTC (permalink / raw)
To: Long Li
Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel, Long Li
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-18 6:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-10 21:07 [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li
2017-05-15 22:48 ` Long Li
2017-05-15 23:20 ` KY Srinivasan
2017-05-15 23:02 ` [Possible Phish Fraud][PATCH] " Bart Van Assche
2017-05-18 6:55 ` [PATCH] " Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox