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 21E4CA0C4B; Thu, 21 Oct 2021 14:28:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1011641216; Thu, 21 Oct 2021 14:28:41 +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 919F5411FB for ; Thu, 21 Oct 2021 14:28:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634819319; 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=E7SVqR+E9JN5uaim4CmhLqtXS1IQruD5VtcjtmTvUG0=; b=fhU/SY7Bw9EGG1d7Ql6CA0vEZdxyiL2MwHDXLTB03DjMlT6HvDWmaN/NAlGhMnYl1J3vr5 tSKKiPvT+XBNsYuprVuBQh2L3LfodSaUYH1Vbv33VQiGZLEs/6EuzbWe79EbYsjbb57ujA VtK1Sw8YhPztjOBRIMKQNc0RcDAzXTI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-L93z1orINrKRfj6dbpMnxQ-1; Thu, 21 Oct 2021 08:28:36 -0400 X-MC-Unique: L93z1orINrKRfj6dbpMnxQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6C83A40C6; Thu, 21 Oct 2021 12:28:34 +0000 (UTC) Received: from [10.39.208.27] (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3168F7944B; Thu, 21 Oct 2021 12:28:32 +0000 (UTC) Message-ID: <87764849-c86f-c9f2-eec5-b0c27b77183e@redhat.com> Date: Thu, 21 Oct 2021 14:28:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: Wenwu Ma , dev@dpdk.org Cc: chenbo.xia@intel.com, cheng1.jiang@intel.com, jiayu.hu@intel.com, yvonnex.yang@intel.com, stable@dpdk.org References: <20210923202946.23266-1-wenwux.ma@intel.com> <20210924172300.26245-1-wenwux.ma@intel.com> From: Maxime Coquelin In-Reply-To: <20210924172300.26245-1-wenwux.ma@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com 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 Subject: Re: [dpdk-dev] [PATCH v2] examples/vhost: fix use-after-free on drain vhost 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 Sender: "dev" On 9/24/21 19:23, Wenwu Ma wrote: > When a vdev is removed in destroy_device function, > the corresponding vhost TX buffer will also be freed, > but the vhost TX buffer may still be used in the > drain_vhost function, which will cause an error of > heap-use-after-free. Therefore, before accessing > vhost TX buffer, we need to check whether the vdev > has been removed, if so, let's skip this vdev. > > Fixes: a68ba8e0a6b6 ("examples/vhost: refactor vhost data path") > Cc: stable@dpdk.org > > Signed-off-by: Wenwu Ma > --- > examples/vhost/main.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index d0bf1f31e3..1f6f7be8e3 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -916,6 +916,9 @@ drain_vhost_table(void) > uint64_t cur_tsc; > > TAILQ_FOREACH(vdev, &vhost_dev_list, global_vdev_entry) { > + if (unlikely(vdev->remove == 1)) > + continue; > + > vhost_txq = vhost_txbuff[lcore_id * MAX_VHOST_DEVICE > + vdev->vid]; > > Applied to dpdk-next-virtio/main. Thanks, Maxime