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 1A0D1A0032; Thu, 17 Feb 2022 09:55:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BEC4410FB; Thu, 17 Feb 2022 09:55:26 +0100 (CET) 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 AEC494113F for ; Thu, 17 Feb 2022 09:55:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645088124; 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=GFEiQNCl6zdAmkuj11yenY3dZLvGXsmJG7gJInhIcQI=; b=VJNosKbUptD33V8kFn4C14+OKt7tlmcj6CZ+0p1tWtGTUp+Rr1eOIyS0IawgxizZlaKb78 b2+Jsg5tAf2cPrAUFa4xvwFDNL7uBbEUEPtTkVc07PTFK3BzAxMDyalHpvVJbD+LLYVZxW U3Hviv0OwliAKwLqg1d33Nrh0QXkFnU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-lEobiGEkOrCYjbu_xkUhqw-1; Thu, 17 Feb 2022 03:55:20 -0500 X-MC-Unique: lEobiGEkOrCYjbu_xkUhqw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1C0E18460E7; Thu, 17 Feb 2022 08:55:19 +0000 (UTC) Received: from [10.39.208.17] (unknown [10.39.208.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E15762D72; Thu, 17 Feb 2022 08:55:16 +0000 (UTC) Message-ID: Date: Thu, 17 Feb 2022 09:55:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] vhost: fix unsafe vrings addresses modifications To: dev@dpdk.org, chenbo.xia@intel.com, yuanx.wang@intel.com, david.marchand@redhat.com Cc: stable@dpdk.org References: <20220127110953.499464-1-maxime.coquelin@redhat.com> From: Maxime Coquelin In-Reply-To: <20220127110953.499464-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 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 1/27/22 12:09, Maxime Coquelin wrote: > This patch adds missing protection around vring_invalidate > and translate_ring_addresses calls in vhost_user_iotlb_msg. > > Fixes: eefac9536a90 ("vhost: postpone device creation until rings are mapped") > Cc: stable@dpdk.org > > Signed-off-by: Maxime Coquelin > --- > lib/vhost/vhost_user.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 5eb1dd6812..ae8513c465 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2566,8 +2566,11 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg, > vhost_user_iotlb_cache_insert(vq, imsg->iova, vva, > len, imsg->perm); > > - if (is_vring_iotlb(dev, vq, imsg)) > + if (is_vring_iotlb(dev, vq, imsg)) { > + rte_spinlock_lock(&vq->access_lock); > *pdev = dev = translate_ring_addresses(dev, i); > + rte_spinlock_unlock(&vq->access_lock); > + } > } > break; > case VHOST_IOTLB_INVALIDATE: > @@ -2580,8 +2583,11 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg, > vhost_user_iotlb_cache_remove(vq, imsg->iova, > imsg->size); > > - if (is_vring_iotlb(dev, vq, imsg)) > + if (is_vring_iotlb(dev, vq, imsg)) { > + rte_spinlock_lock(&vq->access_lock); > vring_invalidate(dev, vq); > + rte_spinlock_unlock(&vq->access_lock); > + } > } > break; > default: Applied to dpdk-next-virtio/main. Thanks, Maxime