vhost: Fix Segmentation fault of NULL address
PATCH 1/1 vhost: Fix Segmentation fault of NULL address
Function gpa_to_vva() could return zero, while this will lead a Segmentation fault.
This patch is to fix this issue.
--- lib/librte_vhost/vhost_rxtx.c | 3 +++ 1 file changed, 3 insertions(+)
lib/librte_vhost/vhost_rxtx.c +3 -0
@@ -587,6 +587,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,/* Buffer address translation. */ vb_addr =gpa_to_vva (dev, desc->addr); +if (!vb_addr) +return entry_success; +/* Prefetch buffer address. */ rte_prefetch0 ((void *)(uintptr_t )vb_addr);
Signature · 1 line
1.9.3
Quoted 15 lines · Michael
Function
gpa_to_vva()could return zero, while this will lead a Segmentation fault.This patch is to fix this issue.
Signed-off-by Michael Qiu <[email protected]>--- lib/librte_vhost/vhost_rxtx.c | 3 +++ 1 file changed, 3 insertions(+)lib/librte_vhost/vhost_rxtx.c +0
-0
lib/librte_vhost/vhost_rxtx.c rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, · line 592
Quoted 6 lines
lib/librte_vhost/vhost_rxtx.c +3
-0@@ -587,6 +587,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,/* Buffer address translation. */ vb_addr =gpa_to_vva (dev, desc->addr); +if (!vb_addr) +return entry_success; +
Firstly we should add check for all gpa_to_vva translation, and do reporting and cleanup on error. We should avoid the case that some buggy or malicious guest virtio driver gives us an invalid GPA(for example, GPA for some MMIO space) and crash our vhost process.
As we discuss, you meet segfault here, but our virtio PMD shouldn't give us the GPA that has no translation, so we should root cause first and fix the problem, and then submit the patch checking all gpa_to_vva translation.
-Huawei
Quoted 3 lines
lib/librte_vhost/vhost_rxtx.c +0
-0/* Prefetch buffer address. */ rte_prefetch0 ((void *)(uintptr_t )vb_addr);
Quoted 17 lines · Huawei
Quoted 16 lines · Michael
Function
gpa_to_vva()could return zero, while this will lead a Segmentation fault.This patch is to fix this issue.
Signed-off-by Michael Qiu <[email protected]>--- lib/librte_vhost/vhost_rxtx.c | 3 +++ 1 file changed, 3 insertions(+)lib/librte_vhost/vhost_rxtx.c +0
-0@@ -587,6 +587,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
Quoted 9 lines
lib/librte_vhost/vhost_rxtx.c rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, · line 592
Quoted 5 lines
lib/librte_vhost/vhost_rxtx.c +3
-0/* Buffer address translation. */ vb_addr =gpa_to_vva (dev, desc->addr); +if (!vb_addr) +return entry_success; +Firstly we should add check for all
gpa_to_vvatranslation, and do reporting and cleanup on error. We should avoid the case that some buggy or malicious guest virtio driver gives us an invalidGPA(for example, GPA for some MMIO space)and crash our vhost process.
Yes, agree, I will do this for next version.
Quoted 2 lines
As we discuss, you meet segfault here, but our virtio PMD shouldn't give us the GPA that has no translation, so we should root cause first and
Yes, root cause is very important, but it will spend lots time, and I think we could be possible to apply this first(All check version).
Thanks,
Michael
Quoted 8 lines
fix the problem, and then submit the patch checking all
gpa_to_vvatranslation.-Huawei
Quoted 3 lines
lib/librte_vhost/vhost_rxtx.c +0
-0/* Prefetch buffer address. */ rte_prefetch0 ((void *)(uintptr_t )vb_addr);
A message that is not in the archive (sent off-list or not yet received): 533710CFB86FA344BFBF2D6802E60286D18871-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Quoted 28 lines · Michael
Quoted 17 lines · Huawei
Quoted 16 lines · Michael
Function
gpa_to_vva()could return zero, while this will lead a Segmentation fault.This patch is to fix this issue.
Signed-off-by Michael Qiu <[email protected]>--- lib/librte_vhost/vhost_rxtx.c | 3 +++ 1 file changed, 3 insertions(+)lib/librte_vhost/vhost_rxtx.c +0
-0@@ -587,6 +587,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,Quoted 9 lines
lib/librte_vhost/vhost_rxtx.c rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, · line 592
Quoted 5 lines
lib/librte_vhost/vhost_rxtx.c +3
-0/* Buffer address translation. */ vb_addr =gpa_to_vva (dev, desc->addr); +if (!vb_addr) +return entry_success; +Firstly we should add check for all
gpa_to_vvatranslation, and do reporting and cleanup on error. We should avoid the case that some buggy or malicious guest virtio driver gives us an invalidGPA(for example, GPA for some MMIO space)and crash our vhost process.
Quoted 8 lines
Yes, agree, I will do this for next version.
Quoted 2 lines
As we discuss, you meet segfault here, but our virtio PMD shouldn't give us the GPA that has no translation, so we should root cause first and
Yes, root cause is very important, but it will spend lots time, and I think we could be possible to apply this first(All check version).
How to deal with invalid address but not NULL?
Quoted 13 lines
Thanks,
MichaelQuoted 8 lines
fix the problem, and then submit the patch checking all
gpa_to_vvatranslation.-Huawei
Quoted 3 lines
lib/librte_vhost/vhost_rxtx.c +0
-0/* Prefetch buffer address. */ rte_prefetch0 ((void *)(uintptr_t )vb_addr);
Quoted 29 lines · Linhaifeng
Quoted 27 lines · Michael
Quoted 26 lines · Huawei
Quoted 15 lines · Michael
Function
gpa_to_vva()could return zero, while this will lead a Segmentation fault.This patch is to fix this issue.
Signed-off-by Michael Qiu <[email protected]>--- lib/librte_vhost/vhost_rxtx.c | 3 +++ 1 file changed, 3 insertions(+)lib/librte_vhost/vhost_rxtx.c +0
-0lib/librte_vhost/vhost_rxtx.c rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, · line 592
Quoted 6 lines
lib/librte_vhost/vhost_rxtx.c +3
-0@@ -587,6 +587,9 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,/* Buffer address translation. */ vb_addr =gpa_to_vva (dev, desc->addr); +if (!vb_addr) +return entry_success; +Firstly we should add check for all
gpa_to_vvatranslation, and do reporting and cleanup on error. We should avoid the case that some buggy or malicious guest virtio driver gives us an invalidGPA(for example, GPA for some MMIO space)and crash our vhost process.
Quoted 8 lines
Quoted 7 lines
Yes, agree, I will do this for next version.
Quoted 2 lines
As we discuss, you meet segfault here, but our virtio PMD shouldn't give us the GPA that has no translation, so we should root cause first and
Yes, root cause is very important, but it will spend lots time, and I think we could be possible to apply this first(All check version).
How to deal with invalid address but not NULL?
The problem is how do you know if it is a valid addres?
Thanks,
Michael
Quoted 13 lines
Quoted 12 lines
Thanks,
MichaelQuoted 7 lines
fix the problem, and then submit the patch checking all
gpa_to_vvatranslation.-Huawei
Quoted 3 lines
lib/librte_vhost/vhost_rxtx.c +0
-0/* Prefetch buffer address. */ rte_prefetch0 ((void *)(uintptr_t )vb_addr);