* [PATCH] vhost/scsi: truncate T10 PI iov_iter to prot_bytes
@ 2018-08-22 19:21 Greg Edwards
2018-09-21 17:49 ` Greg Edwards
0 siblings, 1 reply; 4+ messages in thread
From: Greg Edwards @ 2018-08-22 19:21 UTC (permalink / raw)
To: virtualization; +Cc: Michael S. Tsirkin, Mike Christie, Paolo Bonzini
Commands with protection information included were not truncating the
protection iov_iter to the number of protection bytes in the command.
This resulted in vhost_scsi mis-calculating the size of the protection
SGL in vhost_scsi_calc_sgls(), and including both the protection and
data SG entries in the protection SGL.
Fixes: 09b13fa8c1a1 ("vhost/scsi: Add ANY_LAYOUT support in vhost_scsi_handle_vq")
Signed-off-by: Greg Edwards <gedwards@ddn.com>
---
drivers/vhost/scsi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 76f8d649147b..cbe0ea26c1ff 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -964,7 +964,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesin);
}
/*
- * Set prot_iter to data_iter, and advance past any
+ * Set prot_iter to data_iter and truncate it to
+ * prot_bytes, and advance data_iter past any
* preceeding prot_bytes that may be present.
*
* Also fix up the exp_data_len to reflect only the
@@ -973,6 +974,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
if (prot_bytes) {
exp_data_len -= prot_bytes;
prot_iter = data_iter;
+ iov_iter_truncate(&prot_iter, prot_bytes);
iov_iter_advance(&data_iter, prot_bytes);
}
tag = vhost64_to_cpu(vq, v_req_pi.tag);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost/scsi: truncate T10 PI iov_iter to prot_bytes
2018-08-22 19:21 [PATCH] vhost/scsi: truncate T10 PI iov_iter to prot_bytes Greg Edwards
@ 2018-09-21 17:49 ` Greg Edwards
2018-09-21 17:57 ` Michael S. Tsirkin
2018-09-24 9:09 ` Paolo Bonzini
0 siblings, 2 replies; 4+ messages in thread
From: Greg Edwards @ 2018-09-21 17:49 UTC (permalink / raw)
To: virtualization; +Cc: Paolo Bonzini, Mike Christie, Michael S. Tsirkin
On Wed, Aug 22, 2018 at 01:21:53PM -0600, Greg Edwards wrote:
> Commands with protection information included were not truncating the
> protection iov_iter to the number of protection bytes in the command.
> This resulted in vhost_scsi mis-calculating the size of the protection
> SGL in vhost_scsi_calc_sgls(), and including both the protection and
> data SG entries in the protection SGL.
>
> Fixes: 09b13fa8c1a1 ("vhost/scsi: Add ANY_LAYOUT support in vhost_scsi_handle_vq")
> Signed-off-by: Greg Edwards <gedwards@ddn.com>
Any thoughts on this patch?
> ---
> drivers/vhost/scsi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 76f8d649147b..cbe0ea26c1ff 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -964,7 +964,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
> prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesin);
> }
> /*
> - * Set prot_iter to data_iter, and advance past any
> + * Set prot_iter to data_iter and truncate it to
> + * prot_bytes, and advance data_iter past any
> * preceeding prot_bytes that may be present.
> *
> * Also fix up the exp_data_len to reflect only the
> @@ -973,6 +974,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
> if (prot_bytes) {
> exp_data_len -= prot_bytes;
> prot_iter = data_iter;
> + iov_iter_truncate(&prot_iter, prot_bytes);
> iov_iter_advance(&data_iter, prot_bytes);
> }
> tag = vhost64_to_cpu(vq, v_req_pi.tag);
> --
> 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost/scsi: truncate T10 PI iov_iter to prot_bytes
2018-09-21 17:49 ` Greg Edwards
@ 2018-09-21 17:57 ` Michael S. Tsirkin
2018-09-24 9:09 ` Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2018-09-21 17:57 UTC (permalink / raw)
To: Greg Edwards; +Cc: Paolo Bonzini, Mike Christie, virtualization
On Fri, Sep 21, 2018 at 11:49:12AM -0600, Greg Edwards wrote:
> On Wed, Aug 22, 2018 at 01:21:53PM -0600, Greg Edwards wrote:
> > Commands with protection information included were not truncating the
> > protection iov_iter to the number of protection bytes in the command.
> > This resulted in vhost_scsi mis-calculating the size of the protection
> > SGL in vhost_scsi_calc_sgls(), and including both the protection and
> > data SG entries in the protection SGL.
> >
> > Fixes: 09b13fa8c1a1 ("vhost/scsi: Add ANY_LAYOUT support in vhost_scsi_handle_vq")
> > Signed-off-by: Greg Edwards <gedwards@ddn.com>
>
>
> Any thoughts on this patch?
Paolo could you comment on the virtio-scsi aspects pls?
>
> > ---
> > drivers/vhost/scsi.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> > index 76f8d649147b..cbe0ea26c1ff 100644
> > --- a/drivers/vhost/scsi.c
> > +++ b/drivers/vhost/scsi.c
> > @@ -964,7 +964,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
> > prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesin);
> > }
> > /*
> > - * Set prot_iter to data_iter, and advance past any
> > + * Set prot_iter to data_iter and truncate it to
> > + * prot_bytes, and advance data_iter past any
> > * preceeding prot_bytes that may be present.
> > *
> > * Also fix up the exp_data_len to reflect only the
> > @@ -973,6 +974,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
> > if (prot_bytes) {
> > exp_data_len -= prot_bytes;
> > prot_iter = data_iter;
> > + iov_iter_truncate(&prot_iter, prot_bytes);
> > iov_iter_advance(&data_iter, prot_bytes);
> > }
> > tag = vhost64_to_cpu(vq, v_req_pi.tag);
> > --
> > 2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] vhost/scsi: truncate T10 PI iov_iter to prot_bytes
2018-09-21 17:49 ` Greg Edwards
2018-09-21 17:57 ` Michael S. Tsirkin
@ 2018-09-24 9:09 ` Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2018-09-24 9:09 UTC (permalink / raw)
To: Greg Edwards, virtualization; +Cc: Mike Christie, Michael S. Tsirkin
On 21/09/2018 19:49, Greg Edwards wrote:
> On Wed, Aug 22, 2018 at 01:21:53PM -0600, Greg Edwards wrote:
>> Commands with protection information included were not truncating the
>> protection iov_iter to the number of protection bytes in the command.
>> This resulted in vhost_scsi mis-calculating the size of the protection
>> SGL in vhost_scsi_calc_sgls(), and including both the protection and
>> data SG entries in the protection SGL.
>>
>> Fixes: 09b13fa8c1a1 ("vhost/scsi: Add ANY_LAYOUT support in vhost_scsi_handle_vq")
>> Signed-off-by: Greg Edwards <gedwards@ddn.com>
>
>
> Any thoughts on this patch?
>
>
>> ---
>> drivers/vhost/scsi.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
>> index 76f8d649147b..cbe0ea26c1ff 100644
>> --- a/drivers/vhost/scsi.c
>> +++ b/drivers/vhost/scsi.c
>> @@ -964,7 +964,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
>> prot_bytes = vhost32_to_cpu(vq, v_req_pi.pi_bytesin);
>> }
>> /*
>> - * Set prot_iter to data_iter, and advance past any
>> + * Set prot_iter to data_iter and truncate it to
>> + * prot_bytes, and advance data_iter past any
>> * preceeding prot_bytes that may be present.
>> *
>> * Also fix up the exp_data_len to reflect only the
>> @@ -973,6 +974,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
>> if (prot_bytes) {
>> exp_data_len -= prot_bytes;
>> prot_iter = data_iter;
>> + iov_iter_truncate(&prot_iter, prot_bytes);
>> iov_iter_advance(&data_iter, prot_bytes);
>> }
>> tag = vhost64_to_cpu(vq, v_req_pi.tag);
>> --
>> 2.17.1
Fixes: 09b13fa8c1a1093e9458549ac8bb203a7c65c62a
Cc: stable@vger.kernel.org
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-24 9:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22 19:21 [PATCH] vhost/scsi: truncate T10 PI iov_iter to prot_bytes Greg Edwards
2018-09-21 17:49 ` Greg Edwards
2018-09-21 17:57 ` Michael S. Tsirkin
2018-09-24 9:09 ` Paolo Bonzini
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.