Message ID | 1427353496-21965-1-git-send-email-michael.qiu@intel.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D054437A4; Thu, 26 Mar 2015 08:05:05 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BE1453238 for <dev@dpdk.org>; Thu, 26 Mar 2015 08:05:03 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 26 Mar 2015 00:05:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,469,1422950400"; d="scan'208";a="670801692" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 26 Mar 2015 00:05:02 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t2Q74x21002692; Thu, 26 Mar 2015 15:04:59 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t2Q74vOM021999; Thu, 26 Mar 2015 15:04:59 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t2Q74vgF021995; Thu, 26 Mar 2015 15:04:57 +0800 From: Michael Qiu <michael.qiu@intel.com> To: dev@dpdk.org Date: Thu, 26 Mar 2015 15:04:56 +0800 Message-Id: <1427353496-21965-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] vhost: Fix Segmentation fault of NULL address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Michael Qiu
March 26, 2015, 7:04 a.m. UTC
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 <michael.qiu@intel.com>
---
lib/librte_vhost/vhost_rxtx.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On 3/26/2015 3:05 PM, Qiu, Michael wrote: > 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 <michael.qiu@intel.com> > --- > lib/librte_vhost/vhost_rxtx.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c > index 535c7a1..23c8acb 100644 > --- a/lib/librte_vhost/vhost_rxtx.c > +++ b/lib/librte_vhost/vhost_rxtx.c > @@ -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 > /* Prefetch buffer address. */ > rte_prefetch0((void *)(uintptr_t)vb_addr); >
On 3/26/2015 3:52 PM, Xie, Huawei wrote: > On 3/26/2015 3:05 PM, Qiu, Michael wrote: >> 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 <michael.qiu@intel.com> >> --- >> lib/librte_vhost/vhost_rxtx.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c >> index 535c7a1..23c8acb 100644 >> --- a/lib/librte_vhost/vhost_rxtx.c >> +++ b/lib/librte_vhost/vhost_rxtx.c >> @@ -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. Yes, agree, I will do this for next version. > 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 > fix the problem, and then submit the patch checking all gpa_to_vva > translation. > > -Huawei >> /* Prefetch buffer address. */ >> rte_prefetch0((void *)(uintptr_t)vb_addr); >> >
On 2015/3/26 15:58, Qiu, Michael wrote: > On 3/26/2015 3:52 PM, Xie, Huawei wrote: >> On 3/26/2015 3:05 PM, Qiu, Michael wrote: >>> 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 <michael.qiu@intel.com> >>> --- >>> lib/librte_vhost/vhost_rxtx.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c >>> index 535c7a1..23c8acb 100644 >>> --- a/lib/librte_vhost/vhost_rxtx.c >>> +++ b/lib/librte_vhost/vhost_rxtx.c >>> @@ -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. > > Yes, agree, I will do this for next version. > >> 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? > Thanks, > Michael >> fix the problem, and then submit the patch checking all gpa_to_vva >> translation. >> >> -Huawei >>> /* Prefetch buffer address. */ >>> rte_prefetch0((void *)(uintptr_t)vb_addr); >>> >> > > >
On 3/26/2015 4:29 PM, Linhaifeng wrote: > > On 2015/3/26 15:58, Qiu, Michael wrote: >> On 3/26/2015 3:52 PM, Xie, Huawei wrote: >>> On 3/26/2015 3:05 PM, Qiu, Michael wrote: >>>> 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 <michael.qiu@intel.com> >>>> --- >>>> lib/librte_vhost/vhost_rxtx.c | 3 +++ >>>> 1 file changed, 3 insertions(+) >>>> >>>> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c >>>> index 535c7a1..23c8acb 100644 >>>> --- a/lib/librte_vhost/vhost_rxtx.c >>>> +++ b/lib/librte_vhost/vhost_rxtx.c >>>> @@ -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. >> Yes, agree, I will do this for next version. >> >>> 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 > >> Thanks, >> Michael >>> fix the problem, and then submit the patch checking all gpa_to_vva >>> translation. >>> >>> -Huawei >>>> /* Prefetch buffer address. */ >>>> rte_prefetch0((void *)(uintptr_t)vb_addr); >>>> >> >> >
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c index 535c7a1..23c8acb 100644 --- a/lib/librte_vhost/vhost_rxtx.c +++ b/lib/librte_vhost/vhost_rxtx.c @@ -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);