From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BDC71A00C3; Wed, 22 Jun 2022 02:56:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 613DF4069C; Wed, 22 Jun 2022 02:56:25 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by mails.dpdk.org (Postfix) with ESMTP id F203B40151; Wed, 22 Jun 2022 02:56:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=USfkO wFvNwBdnelSJPscArTFpAI+eXCG7iTm4T6D8nc=; b=H5TzffFgTH+G1zjI+UuYr qC4hh1KwRWVWdtLShSjrfosv3NY5u9Dut8FZw9EIzVuULYmJaFlyfdFsESY91vvN yWTcWFe/a+y8MpfqloC0H0UNyk0vRlLuZG73cG35paB4Bd+fXGHliZ5wOkinrF1A nl1Qul8aBLVuU5B9p0Grnw= Received: from DESKTOP-ONA2IA7.localdomain (unknown [223.104.244.95]) by smtp9 (Coremail) with SMTP id DcCowAD3ECykaLJiJ9Q_Kg--.30054S4; Wed, 22 Jun 2022 08:56:15 +0800 (CST) From: Gaoxiang Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, liugaoxiang@huawei.com, Gaoxiang Liu , stable@dpdk.org Subject: [PATCH] vhost: fix avail idx update error when desc copy failed Date: Wed, 22 Jun 2022 08:56:00 +0800 Message-Id: <20220622005600.5920-1-gaoxiangliu0@163.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: DcCowAD3ECykaLJiJ9Q_Kg--.30054S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7JF4DZr4rJw48JF13GrW3Wrg_yoWDArb_uF y7Ar17ZFZ5JFsY9w45Aan3tws29a1xGF18C3WrAr1fWFyUAa1DZ3ZYyr98AF17Ww43ArW3 AFs8Jrn7tw1fWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRtdbbJUUUUU== X-Originating-IP: [223.104.244.95] X-CM-SenderInfo: xjdr5xxdqjzxjxq6il2tof0z/xtbBORAoOl-POEdnbgAAsd 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 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 --- lib/vhost/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 68a26eb17d..86f1c04b43 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -2850,7 +2850,7 @@ 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 - 1; do_data_copy_dequeue(vq); if (unlikely(i < count)) -- 2.32.0