DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags
       [not found] <CGME20181205150935eucas1p11698df8ed58ff02a4326dd5780af4470@eucas1p1.samsung.com>
@ 2018-12-05 15:09 ` Ilya Maximets
  2018-12-11 14:47   ` Maxime Coquelin
  2018-12-11 18:33   ` Maxime Coquelin
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Maximets @ 2018-12-05 15:09 UTC (permalink / raw)
  To: dev, Maxime Coquelin
  Cc: Tiwei Bie, Zhihong Wang, jfreimann, Ilya Maximets, stable

Flags could be updated in a separate process leading to the
inconsistent check.

Additionally, read marked as 'volatile' to highlight the shared
nature of the variable and avoid such issues in the future.

Fixes: d3211c98c456 ("vhost: add helpers for packed virtqueues")
Cc: stable@dpdk.org

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 lib/librte_vhost/vhost.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 5218f1b12..84cbee2b6 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -393,8 +393,10 @@ vq_is_packed(struct virtio_net *dev)
 static inline bool
 desc_is_avail(struct vring_packed_desc *desc, bool wrap_counter)
 {
-	return wrap_counter == !!(desc->flags & VRING_DESC_F_AVAIL) &&
-		wrap_counter != !!(desc->flags & VRING_DESC_F_USED);
+	uint16_t flags = *((volatile uint16_t *) &desc->flags);
+
+	return wrap_counter == !!(flags & VRING_DESC_F_AVAIL) &&
+		wrap_counter != !!(flags & VRING_DESC_F_USED);
 }
 
 #define VHOST_LOG_PAGE	4096
-- 
2.17.1

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

* Re: [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags
  2018-12-05 15:09 ` [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags Ilya Maximets
@ 2018-12-11 14:47   ` Maxime Coquelin
  2018-12-11 18:33   ` Maxime Coquelin
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2018-12-11 14:47 UTC (permalink / raw)
  To: Ilya Maximets, dev; +Cc: Tiwei Bie, Zhihong Wang, jfreimann, stable



On 12/5/18 4:09 PM, Ilya Maximets wrote:
> Flags could be updated in a separate process leading to the
> inconsistent check.
> 
> Additionally, read marked as 'volatile' to highlight the shared
> nature of the variable and avoid such issues in the future.
> 
> Fixes: d3211c98c456 ("vhost: add helpers for packed virtqueues")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>   lib/librte_vhost/vhost.h | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 5218f1b12..84cbee2b6 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -393,8 +393,10 @@ vq_is_packed(struct virtio_net *dev)
>   static inline bool
>   desc_is_avail(struct vring_packed_desc *desc, bool wrap_counter)
>   {
> -	return wrap_counter == !!(desc->flags & VRING_DESC_F_AVAIL) &&
> -		wrap_counter != !!(desc->flags & VRING_DESC_F_USED);
> +	uint16_t flags = *((volatile uint16_t *) &desc->flags);
> +
> +	return wrap_counter == !!(flags & VRING_DESC_F_AVAIL) &&
> +		wrap_counter != !!(flags & VRING_DESC_F_USED);
>   }
>   
>   #define VHOST_LOG_PAGE	4096
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

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

* Re: [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags
  2018-12-05 15:09 ` [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags Ilya Maximets
  2018-12-11 14:47   ` Maxime Coquelin
@ 2018-12-11 18:33   ` Maxime Coquelin
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2018-12-11 18:33 UTC (permalink / raw)
  To: Ilya Maximets, dev; +Cc: Tiwei Bie, Zhihong Wang, jfreimann, stable



On 12/5/18 4:09 PM, Ilya Maximets wrote:
> Flags could be updated in a separate process leading to the
> inconsistent check.
> 
> Additionally, read marked as 'volatile' to highlight the shared
> nature of the variable and avoid such issues in the future.
> 
> Fixes: d3211c98c456 ("vhost: add helpers for packed virtqueues")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>   lib/librte_vhost/vhost.h | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 5218f1b12..84cbee2b6 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -393,8 +393,10 @@ vq_is_packed(struct virtio_net *dev)
>   static inline bool
>   desc_is_avail(struct vring_packed_desc *desc, bool wrap_counter)
>   {
> -	return wrap_counter == !!(desc->flags & VRING_DESC_F_AVAIL) &&
> -		wrap_counter != !!(desc->flags & VRING_DESC_F_USED);
> +	uint16_t flags = *((volatile uint16_t *) &desc->flags);
> +
> +	return wrap_counter == !!(flags & VRING_DESC_F_AVAIL) &&
> +		wrap_counter != !!(flags & VRING_DESC_F_USED);
>   }
>   
>   #define VHOST_LOG_PAGE	4096
> 

Applied to dpdk-next-virtio.

Thanks,
Maxime

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

end of thread, other threads:[~2018-12-11 18:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20181205150935eucas1p11698df8ed58ff02a4326dd5780af4470@eucas1p1.samsung.com>
2018-12-05 15:09 ` [dpdk-dev] [PATCH] vhost: fix double read of descriptor flags Ilya Maximets
2018-12-11 14:47   ` Maxime Coquelin
2018-12-11 18:33   ` Maxime Coquelin

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).