From patchwork Wed Jun 22 14:30:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaoxiang Liu X-Patchwork-Id: 113255 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C190AA0093; Wed, 22 Jun 2022 16:30:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61EBE40A84; Wed, 22 Jun 2022 16:30:15 +0200 (CEST) Received: from m13119.mail.163.com (m13119.mail.163.com [220.181.13.119]) by mails.dpdk.org (Postfix) with ESMTP id 3CED34069F for ; Wed, 22 Jun 2022 16:30:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=yYkYe 8oJPdFgnSu3FWO9Mx3L+3WKrmdNApYKq+51ev0=; b=KLLKn3lN/Yi/Xjnhok1w0 GhmovUmnKH2xbcvz13kofZiHP/YKxqJe7NvSo7bFjShvn496zOnyWpKhVFbnGcjK AzzuSNkNF9bQTII3Bb2MaFvKCRAwV0YThH8rm3YFVi+omKGiL0I3FnsTTNZC3VTe xnNFoZL2mkuv+btVo7TgSI= Received: from gaoxiangliu0$163.com ( [218.72.103.125] ) by ajax-webmail-wmsvr119 (Coremail) ; Wed, 22 Jun 2022 22:30:08 +0800 (CST) X-Originating-IP: [218.72.103.125] Date: Wed, 22 Jun 2022 22:30:08 +0800 (CST) From: "Gaoxiang Liu" To: "Xia, Chenbo" , maxime.coquelin@redhat.com Cc: dev@dpdk.org Subject: Fw:[PATCH v2] vhost: fix avail idx update error when desc copy failed X-Priority: 3 X-Mailer: Coremail Webmail Server Version XT5.0.13 build 20220113(9671e152) Copyright (c) 2002-2022 www.mailtech.cn 163com MIME-Version: 1.0 Message-ID: <3603f2dd.5f97.1818bd20f65.Coremail.gaoxiangliu0@163.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: d8GowACXdytwJ7NiWikWAA--.16361W X-CM-SenderInfo: xjdr5xxdqjzxjxq6il2tof0z/1tbi6wkoOlXl2MsGbAACs7 X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi, Chen bo, Maxime, Please help to review the patch below. Thanks. Gaoxiang. -------- Forwarding messages -------- From: "Gaoxiang Liu" Date: 2022-06-22 09:19:44 To: maxime.coquelin@redhat.com,chenbo.xia@intel.com Cc: dev@dpdk.org,liugaoxiang@huawei.com,"Gaoxiang Liu" ,stable@dpdk.org Subject: [PATCH v2] vhost: fix avail idx update error when desc copy failed When copy_desc_to_mbuf function failed, i added 1. And last_avail_idx added i, other than i - 1. It may cause that the first mbuf in mbuf-list is dropped, the second mbuf in mbuf-list is received in the following rx procedure. And The pkt_len of the second mbuf is zero, resulting in segment fault when parsing the mbuf. Fixes: 0fd5608ef97f ("vhost: handle mbuf allocation failure") Cc: stable@dpdk.org Signed-off-by: Gaoxiang Liu Signed-off-by: Gaoxiang Liu --- v2: * Fixed other idx update errors. --- lib/vhost/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 68a26eb17d..eb254e1024 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -2850,11 +2850,11 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, if (dropped) rte_pktmbuf_free_bulk(&pkts[i - 1], count - i + 1); - vq->last_avail_idx += i; + vq->last_avail_idx += i - dropped; do_data_copy_dequeue(vq); - if (unlikely(i < count)) - vq->shadow_used_idx = i; + if (unlikely((i - dropped) < count)) + vq->shadow_used_idx = i - dropped; if (likely(vq->shadow_used_idx)) { flush_shadow_used_ring_split(dev, vq); vhost_vring_call_split(dev, vq);