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 B2F2445D27 for ; Mon, 25 Nov 2024 12:14:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7809402C9; Mon, 25 Nov 2024 12:14:56 +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 A272F402C9 for ; Mon, 25 Nov 2024 12:14:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732533294; 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=fiIpHj2yik2Rg0M7pQZy3IGMcBro2VA7Jd6VVPjf4JOadHqbfHt7hdmNNIyGzLeeoxqtdA X3ddxs9dCE3noP7Ee+NGQYXqzf8ev/JAHxfyrhnORvS79i06C85+zg0WkH3tVvNerGCACv ft1FQAHE9maHnr2KxJU05vnOAc+L+IU= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-JLrVQk4APQGY6tvGILQDWQ-1; Mon, 25 Nov 2024 06:14:53 -0500 X-MC-Unique: JLrVQk4APQGY6tvGILQDWQ-1 X-Mimecast-MFC-AGG-ID: JLrVQk4APQGY6tvGILQDWQ Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53de65ce406so275303e87.1 for ; Mon, 25 Nov 2024 03:14:50 -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=cZ5IHDwmhB1cAePWgnpnDUZKyiGLrX096WkNzJS0Dm/Ulua5JMAREcXneFkydUeH8O hbO91MhViS7X4k1irztJyPbBH3tJ8iiqYKRsACpTPwhEtzcaW4yQelqI+Mg5ut/c5A3s 6HiWp2TQq/H7ewx+RkwqQWhUKiFwebgv32XDPU+blv9m/DTi+xfFVSLhBWIq3eJbLQqk aghEyB7AGJWWedWngYaTIx6rRoej397yEgPy238d6qfUmZIQLJXaIdX81heZW6bluSl8 Un2Hwf+z0ubXgNgv6Ot42fF5gqO8Y6idvFG81NimWzTUvekAkApLmm+6KNPtK5WCWxuM a/Fw== X-Forwarded-Encrypted: i=1; AJvYcCX7XQQlBMJwuKA1SGUlMQIawnVz+mDMsKDA+DyNl221f/2Fd/odkdJCrMDvecFl6ORTOmQG2B4=@dpdk.org X-Gm-Message-State: AOJu0YyQTm8kpnDiqfo5geVnKrjHwr4y37rkJTUik48Mw7dqkRWwAqZn FiNv80iOQL0Rohui93bHuuw/MVHOjsOxt9LYLxG4+L+NOKKRRBbL7AuHfPBrwHeLbQ0b48Ilvb9 IFE2Ew8ULlmgbDJ8yChLNv6hqlOKK+4vf0t1NEoERXj/edmvd53cG4urzIVNMRApBArOj+x+mzG fT4uqMRMO+khu7A7PZRlU= X-Gm-Gg: ASbGncsxY8IyrpdAocAYsK7XycTgtIQ+Xev5Cbwcmx+9LN2yllah5gtbtMnG3fZeK4T 4Fsm074mRoNHQhLMCZxs9Ou5FjS3IYIKidA== X-Received: by 2002:a05:6512:3ba6:b0:53d:e70d:f3b7 with SMTP id 2adb3069b0e04-53de70df64bmr412526e87.53.1732533286316; 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: mRzqSfdV1ySGHE2Vem-7ADmefWQsrP-nqUxuAxaimn0_1732533286 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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