From patchwork Tue Dec 5 09:45:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 134872 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 15C0E43676; Tue, 5 Dec 2023 10:46:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55B3742E27; Tue, 5 Dec 2023 10:45:59 +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 90CDB42E25 for ; Tue, 5 Dec 2023 10:45:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701769556; 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=zt5/CAg6SUQmZ+ORbBV/0XJpbhMd61fqfgZSknQ9xVI=; b=SMtH//MvbxHrlfPXJ65GQBBn+NZvG7RLA7ia5MIzodK62bzZJwf3alhId6HvbjgP4/64wE DZiLWKCpOqIi/q3fn+bLAi6Ll7NGXZPTJq0xYH62vNfcNcYXHk9xhiGBISIJViCceKSiNU qnmsu1WZgeI9WxvUVbKLIISBTjpVHYc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-xNvFzpF_PDiHSXHe5FgkPg-1; Tue, 05 Dec 2023 04:45:52 -0500 X-MC-Unique: xNvFzpF_PDiHSXHe5FgkPg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C24643CBDFAD; Tue, 5 Dec 2023 09:45:51 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 891F71C060AF; Tue, 5 Dec 2023 09:45:50 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Eelco Chaudron , Maxime Coquelin , Chenbo Xia , Tiwei Bie Subject: [PATCH v2 3/5] vhost: fix virtqueue access check in vhost-user setup Date: Tue, 5 Dec 2023 10:45:33 +0100 Message-ID: <20231205094536.2816720-3-david.marchand@redhat.com> In-Reply-To: <20231205094536.2816720-1-david.marchand@redhat.com> References: <20231023095520.2864868-1-david.marchand@redhat.com> <20231205094536.2816720-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Calling vring_invalidate must be done with a (write) lock taken on the virtqueue. Fixes: 72d002b3ebda ("vhost: fix vring address handling during live migration") Cc: stable@dpdk.org Signed-off-by: David Marchand Acked-by: Eelco Chaudron Reviewed-by: Maxime Coquelin --- Changes since v1: - moved fix out of patch 3, --- lib/vhost/vhost_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index e36312181a..a323ce5fbf 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -2198,7 +2198,9 @@ vhost_user_get_vring_base(struct virtio_net **pdev, vhost_user_iotlb_flush_all(dev); + rte_rwlock_write_lock(&vq->access_lock); vring_invalidate(dev, vq); + rte_rwlock_write_unlock(&vq->access_lock); return RTE_VHOST_MSG_RESULT_REPLY; }