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 A853645D27; Mon, 25 Nov 2024 12:14:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B7564067B; Mon, 25 Nov 2024 12:14:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B8CCB402C9 for ; Mon, 25 Nov 2024 12:14:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732533289; 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=NEPP5G8JLqYLAtqVEN7WuSlixXB3A5KAj2QzImvZiO0=; b=f5KuS02VmxGfUqX3nFE47l9lt64sFl9mLMcqHBqx8Vw50iJvYd2/DgTcbfu4CqknfByS56 H3LsyAmA3EteC5OHFHBbh4zXg8blPogvLoNb7yIdZcLlzoWTxAoNUAkNUjUdYto3u3V5va tNarB0EtBYKyx5YDMWDg1TbhaBbGrmw= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-70ClVGWtPH-5WHbsKGvuig-1; Mon, 25 Nov 2024 06:14:47 -0500 X-MC-Unique: 70ClVGWtPH-5WHbsKGvuig-1 X-Mimecast-MFC-AGG-ID: 70ClVGWtPH-5WHbsKGvuig Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-53de05235ccso595115e87.0 for ; Mon, 25 Nov 2024 03:14:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732533286; x=1733138086; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NEPP5G8JLqYLAtqVEN7WuSlixXB3A5KAj2QzImvZiO0=; b=L6uixpf3iEeU7u4Ww21QWBTZSVP9k6XJMYsgbM8pib2U14jZO9LqPPCGEfqb1M8nxZ Aj02boe/gO6h+AhB+s9znZDmJAME9rH+TVdcc0VAOiuewJ9cne7HDuGlPLbxm+aH0baL RIKenwHoVlBgqm7sl23jm1kTl+U9tgxDw7W4whZwUsCbVXvHaic9jScQSYexjVmsLAiS wxnRuB7hg3A2xk4HrKFTNh/BjYhmR/sF1eaUN8375RKkGcV58UA+2BV73D8uRowQg0DE FW+cCv1BWEzoy+hTthI5ERBagqy76gstVYZB61PmcuLWzhI4294dHKzpXAw3x3mGJoxx A5+Q== X-Gm-Message-State: AOJu0YxZoFeUiskWwPPWyjTkHSHJj7NcTNFKCqdLhvEDTjeD1rtdeXyD 9TvUwsojmLGnMVxhTMyvUPzoZEQh8cqNfb8htMmkVMOa2JBaES9FjLD/jUBFCbvp33cfQGX41iV 3JT49+FeYIoWR4vjDMvmbY+GY8sWk9BVmdGWzrVCbV7iA0OFqLG5J8RXXaG9M/nMz7UUzKtV+pp SKfagf3so+elT2fso= X-Gm-Gg: ASbGncv1N6ddGi25w8U7jWG/RpSKC3NbUh5SegItHPtTLYltHEUlMWEUO4ExxhD/ZnG xvdJcKk61AB9B/rp6EnynNsNpQ8Z1WSlyYQ== X-Received: by 2002:a05:6512:3ba6:b0:53d:e70d:f3b7 with SMTP id 2adb3069b0e04-53de70df64bmr412522e87.53.1732533286311; Mon, 25 Nov 2024 03:14:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCpvaixhUR2IJ+HonToDbFC0IptnUJ+ze5ZBdegx7LZhn0apiZssp9mNCf2UCVHDqLni9gFm96OlGUuHHJq14= X-Received: by 2002:a05:6512:3ba6:b0:53d:e70d:f3b7 with SMTP id 2adb3069b0e04-53de70df64bmr412508e87.53.1732533285947; Mon, 25 Nov 2024 03:14:45 -0800 (PST) MIME-Version: 1.0 References: <20241118162424.9038-1-stephen@networkplumber.org> In-Reply-To: <20241118162424.9038-1-stephen@networkplumber.org> From: David Marchand Date: Mon, 25 Nov 2024 12:14:35 +0100 Message-ID: Subject: Re: [PATCH] vhost: fix read vs write lock mismatch To: Stephen Hemminger Cc: dev@dpdk.org, stable@dpdk.org, Maxime Coquelin , Chenbo Xia , Eelco Chaudron X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5UY-z1KYqvkLhE-J3MJyHww3dtiCwn7oiYtbwV922E8_1732533286 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Mon, Nov 18, 2024 at 5:24=E2=80=AFPM Stephen Hemminger wrote: > > If lock is acquired for write, it must be released for write > or a deadlock is likely. > > Bugzilla ID: 1582 > Fixes: 9fc93a1e2320 ("vhost: fix virtqueue access check in datapath") > Cc: david.marchand@redhat.com > Cc: stable@dpdk.org > > Signed-off-by: Stephen Hemminger > --- > 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 298a5dae74..d764d4bc6a 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -2538,7 +2538,7 @@ virtio_dev_rx_async_submit(struct virtio_net *dev, = struct vhost_virtqueue *vq, > > if (unlikely(!vq->access_ok)) { > vhost_user_iotlb_rd_unlock(vq); > - rte_rwlock_read_unlock(&vq->access_lock); > + rte_rwlock_write_unlock(&vq->access_lock); A write lock is taken earlier, because virtio_dev_rx_async_submit_* need it for access to vq->async (as opposed to the sync code that only takes read lock). Here, no need to release/take again all locks. A simpler fix is to directly call vring_translate(dev, vq). --=20 David Marchand