Skip to contentSkip to conversation

vhost_user: Make sure that memory map is set before attempting address translation

PATCH RESEND Applied Pavel Fedin 3 participants 7 messages Jan 13, 2016 – Feb 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 vhost_user: Make sure that memory map is set before attempting address translation

Malfunctioning virtio clients may not send VHOST_USER_SET_MEM_TABLE for some reason. This causes NULL dereference in qva_to_vva().

---
 lib/librte_vhost/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_vhost/virtio-net.c +1 -1
index 0ba5045..3e7cec0 100644
@@ -630,7 +630,7 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
 	struct vhost_virtqueue *vq;
 
 	dev = get_device(ctx);
-	if (dev == NULL)
+	if ((dev == NULL) || (dev->mem == NULL))
 		return -1;
 
 	/* addr->index refers to the queue index. The txq 1, rxq is 0. */
Signature · 1 line
2.1.1
#1 lore raw
Quoted 2 lines · Pavel Fedin

Malfunctioning virtio clients may not send VHOST_USER_SET_MEM_TABLE for some reason. This causes NULL dereference in qva_to_vva().

Do you have examples for the malfunctioning clients? If so, could you list them in the commit message?

Quoted 20 lines
---
 lib/librte_vhost/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_vhost/virtio-net.c +1 -1
index 0ba5045..3e7cec0 100644
@@ -630,7 +630,7 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
 	struct vhost_virtqueue *vq;
 
 	dev = get_device(ctx);
-	if (dev == NULL)
+	if ((dev == NULL) || (dev->mem == NULL))
 		return -1;
 
 	/* addr->index refers to the queue index. The txq 1, rxq is 0. */
#2 lore raw

Hello!

Quoted 2 lines

Do you have examples for the malfunctioning clients? If so, could you list them in the commit message?

The only malfunctioning client was DPDK itself, with virtio for container RFC applied. The client-side problem has been fixed
afterwards by http://dpdk.org/ml/archives/dev/2016-January/031169.html. See the RFC discussion thread.

Kind regards,
Pavel Fedin
Senior Engineer
Samsung Electronics Research center Russia

#3 lore raw
Quoted 6 lines · Pavel Fedin

Hello!

Quoted 2 lines

Do you have examples for the malfunctioning clients? If so, could you list them in the commit message?

The only malfunctioning client was DPDK itself, with virtio for container RFC applied. The client-side problem has been fixed
afterwards by http://dpdk.org/ml/archives/dev/2016-January/031169.html. See the RFC discussion thread.

If this is the case, i am wondering whether we should include "malfunctioning clients" in commit message. It triggers me to think if there are existing buggy implementations.

Anyway, check is OK.

Quoted 7 lines

Kind regards,
Pavel Fedin
Senior Engineer
Samsung Electronics Research center Russia

#4 lore raw

Hello!

Quoted 3 lines

If this is the case, i am wondering whether we should include "malfunctioning clients" in commit message. It triggers me to think if there are existing buggy implementations.

Well... Can you suggest how to rephrase it? May be "if a client is malfunctioning it can..."? I lack fantasy, really, and to tell
the truth i don't care that much about the exact phrasing, i'm OK with everything.

Quoted 1 line

Anyway, check is OK.

Kind regards,
Pavel Fedin
Senior Engineer
Samsung Electronics Research center Russia

#5 lore raw
Quoted 7 lines · Pavel Fedin

Hello!

Quoted 3 lines

If this is the case, i am wondering whether we should include "malfunctioning clients" in commit message. It triggers me to think if there are existing buggy implementations.

Well... Can you suggest how to rephrase it? May be "if a client is malfunctioning it can..."? I lack fantasy, really, and to tell
the truth i don't care that much about the exact phrasing, i'm OK with everything.

Thanks.
Because there are not any existing malfunctioning clients which doesn't send SET_MEM_TABLE message and we think the check is OK anyway, personally I prefer simple phrases like: check memory table in SET_VRING_ADDR message.

Quoted 9 lines
Quoted 2 lines

Anyway, check is OK.

Kind regards,
Pavel Fedin
Senior Engineer
Samsung Electronics Research center Russia