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 2C0BDA0542; Wed, 5 Oct 2022 14:57:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C542C40694; Wed, 5 Oct 2022 14:57:42 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1F1A140143 for ; Wed, 5 Oct 2022 14:57:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664974660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VKFwXm+qToRLXyrltvVUNWtJdLu+sTB4mv53qDWfA8Q=; b=LwD82EK2tjmQkUpbf5c/q4MgFglVVu8RGHDaOlgsYnLLIzgmiAzT6N+eav0u/4quh7aVmt WlaNDJyVWt7NUNA8jALg089o5/GEJLSZvuUKfQcPHnG+alNiaQC1Y9CarqAfSupL4VcQof tHwZOhBTYQLyJD7Jy2ojMRr7XmAKj48= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-354-wnJCtq_EN9SxBulKgFu-fw-1; Wed, 05 Oct 2022 08:57:39 -0400 X-MC-Unique: wnJCtq_EN9SxBulKgFu-fw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CAF8811E81; Wed, 5 Oct 2022 12:57:39 +0000 (UTC) Received: from [10.39.208.19] (unknown [10.39.208.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EEDC40C6DC8; Wed, 5 Oct 2022 12:57:38 +0000 (UTC) Message-ID: Date: Wed, 5 Oct 2022 14:57:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v3 2/2] vhost: improve error handling in desc_to_mbuf To: Claudio Fontana , Chenbo Xia Cc: dev@dpdk.org References: <20220802004938.23670-1-cfontana@suse.de> <20220802004938.23670-3-cfontana@suse.de> From: Maxime Coquelin In-Reply-To: <20220802004938.23670-3-cfontana@suse.de> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 8/2/22 02:49, Claudio Fontana wrote: > check when increasing vec_idx that it is still valid > in the (buf_len < dev->vhost_hlen) case too. > > Tested-by: Claudio Fontana > Signed-off-by: Claudio Fontana > --- > lib/vhost/virtio_net.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index eb19e54c2b..20ed951979 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -2704,12 +2704,15 @@ desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq, > if (unlikely(buf_len < dev->vhost_hlen)) { > buf_offset = dev->vhost_hlen - buf_len; > vec_idx++; > + if (unlikely(vec_idx >= nr_vec)) > + goto error; > buf_addr = buf_vec[vec_idx].buf_addr; > buf_iova = buf_vec[vec_idx].buf_iova; > buf_len = buf_vec[vec_idx].buf_len; > buf_avail = buf_len - buf_offset; > } else if (buf_len == dev->vhost_hlen) { > - if (unlikely(++vec_idx >= nr_vec)) > + vec_idx++; > + if (unlikely(vec_idx >= nr_vec)) > goto error; > buf_addr = buf_vec[vec_idx].buf_addr; > buf_iova = buf_vec[vec_idx].buf_iova; This patch is no more required since fixes for CVE-2022-2132 takes care of this: dc1516e260a0 ("vhost: fix header spanned across more than two descriptors") 71bd0cc536ad ("vhost: discard too small descriptor chains") Maxime