From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) by dpdk.org (Postfix) with ESMTP id 3ABE8181 for ; Thu, 26 Mar 2015 09:29:21 +0100 (CET) Received: from 172.24.2.119 (EHLO szxeml425-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CIZ50361; Thu, 26 Mar 2015 16:29:10 +0800 (CST) Received: from [127.0.0.1] (10.177.19.115) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.158.1; Thu, 26 Mar 2015 16:29:07 +0800 Message-ID: <5513C350.9090609@huawei.com> Date: Thu, 26 Mar 2015 16:29:04 +0800 From: Linhaifeng User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: "Qiu, Michael" , "Xie, Huawei" References: <1427353496-21965-1-git-send-email-michael.qiu@intel.com> <533710CFB86FA344BFBF2D6802E60286D18871@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286D18871@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.19.115] X-CFilter-Loop: Reflected Cc: "dev@dpdk.org" Subject: Re: [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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2015 08:29:23 -0000 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 >>> --- >>> 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); >>> >> > > >