From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id E2B72467FD
	for <public@inbox.dpdk.org>; Mon, 26 May 2025 23:14:07 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id D840840664;
	Mon, 26 May 2025 23:14:07 +0200 (CEST)
Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com
 [209.85.218.53]) by mails.dpdk.org (Postfix) with ESMTP id 7A41240653
 for <stable@dpdk.org>; Mon, 26 May 2025 23:14:06 +0200 (CEST)
Received: by mail-ej1-f53.google.com with SMTP id
 a640c23a62f3a-ad52dfe06ceso324710066b.3
 for <stable@dpdk.org>; Mon, 26 May 2025 14:14:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1748294046;
 x=1748898846; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:from:to:cc:subject:date
 :message-id:reply-to;
 bh=92oh9o4h+FMe52u2IgQCQPoGnbx7/4V+JJyZXAmbikA=;
 b=SqD63SG+JUmzSAPFjQqjri4nbXIgxhX3AmsU+3gQrY67aVrU3xQxcJKo9S5at6Cde1
 WNlccTaQnbifbSr/2A4pe0mNq2BBimXyYcdwMF52vxgxyUabW51tYyiun4IaDvu0um5H
 DhCCDxQGZuF0+wSbAyridj9kbCq0opYM9LhqrarvgfZk8wKzemmhh+hNGPUs8YYcVhH5
 Of7g2s+LFNcSRWMxGwuc+hmtYcNweB86VfnMQMpDSACoO+fPzMTbFQTfxTOHLwiDijN6
 6gk9kCGL3pH9/4vdzWOSEAGNQuu9cbiOXcwtfmb7HYqCTsUVsHL73FP3y8WAUP4l6EtN
 PMew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1748294046; x=1748898846;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=92oh9o4h+FMe52u2IgQCQPoGnbx7/4V+JJyZXAmbikA=;
 b=YYTPVOT7xVnD9sPw4gBwWkT3y7Sv0fk0I/GHhlp7gfHZbKfwj/uUc/om4K9U5w6YPO
 HMhfcYGVYfTL3PcruU3UtJ+HAQmG+9s06+KmMkuzHk0/6vbwkfyac0eK5cTeUt/spFA0
 mWPTmQUbT3cbUu3CfVFrLfecGml0wmStGQVJCHtsj7HGFkhW4VMUHd66OOb1glyL4hlg
 g0Y03Q1GAR3wlMkb2ec9BoiZ5zpNLYFCe8Ngq082XU+21aEf3/uDyA4Xl3c7LcsAbG3E
 tVtf3Gd/4UKTEgkQujb1N30jRQSpw5tQ60+9aFp2OUG/nfj6m9Egs5pLpjDovO0FSBKn
 5Jmg==
X-Forwarded-Encrypted: i=1;
 AJvYcCVBabzhwmdhgnEGSrzw3pqZChpDQY+VyUTOgO94FIWXHQyPLOwut8+1VntbYlWP/JyXBvtq2V4=@dpdk.org
X-Gm-Message-State: AOJu0YyiYhv9/L6IBQ/PHdDUxsvJt/uRigBmxMfyEZvXHOB5S8oEIjOp
 w5wf3K7ybZ8NgVozvHgmypneU+qwJSMSq4ya4aGz9JVfQOy8zemwpJLiUpXnOEAtm3I=
X-Gm-Gg: ASbGncujajvPpoA3VWqVfcmKk1UTbGGupU1rstoAEluQ8ABmTj2yOiaCKi3lbaZW5Rf
 Ep4ou6Rb1Xq3LJjVHtMko8EuNSOvEDxSlaXqwm9oN5yq1r5wBfdPNvkgIoY3DsCXLMsYaCWyPJt
 BYPU2srxEcWnavfssh+rv7o5fMR/6iL373agXCYi6xOfK2DkXPEdeZfTlFsZJ1WjOryXUhUibSz
 kZUPgBofPjd5laF5s6X42iEqFlHxVqXSPKp/0v6j/VgcgPDERjcIZFEZCRL5fjaZO8bhGZX+JEh
 /1RSiDGw9DUW4KoZSkSUJNr3a5rYExT6LfggIMvHeO7uhvgsAudT3rTPa1Kd9AolFuVbZYxkUR1
 SfeyMWKd6r7seq/8dQScNQatX71Q1
X-Google-Smtp-Source: AGHT+IFAGe3xazn8//hoSwRa+Hvucf0iGhCYXLYNnibOmPPzwnmsxZzXVKykfj4XZpIIABeJecnshQ==
X-Received: by 2002:a17:906:f587:b0:ad5:6d1a:6fa4 with SMTP id
 a640c23a62f3a-ad85b22bbfdmr903195666b.44.1748294046042; 
 Mon, 26 May 2025 14:14:06 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-ad52d43840esm1724960466b.87.2025.05.26.14.14.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 26 May 2025 14:14:05 -0700 (PDT)
Date: Mon, 26 May 2025 14:14:00 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: Gongming Chen <chengongming1900@outlook.com>
Cc: maxime.coquelin@redhat.com, chenbox@nvidia.com, dev@dpdk.org, Gongming
 Chen <chengm11@chinatelecom.cn>, stable@dpdk.org
Subject: Re: [PATCH v4] vhost: fix crash caused by accessing a freed vsocket
Message-ID: <20250526141400.552bd764@hermes.local>
In-Reply-To: <TYAP286MB06491A9489C631C9D6EEA2FFD8DA2@TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM>
References: <TYAP286MB06494783C3973058BF499642D83D2@TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM>
 <TYAP286MB06491A9489C631C9D6EEA2FFD8DA2@TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org

On Mon,  8 Jul 2024 12:41:03 +0800
Gongming Chen <chengongming1900@outlook.com> wrote:

> diff --git a/lib/vhost/vhost_thread.c b/lib/vhost/vhost_thread.c
> new file mode 100644
> index 0000000000..f3ff182976
> --- /dev/null
> +++ b/lib/vhost/vhost_thread.c
> @@ -0,0 +1,33 @@
> +#include <rte_rwlock.h>
> +
> +#include "vhost_thread.h"
> +
> +static rte_rwlock_t vhost_thread_lock = RTE_RWLOCK_INITIALIZER;
> +
> +void
> +vhost_thread_read_lock(void)
> +	__rte_no_thread_safety_analysis
> +{
> +	rte_rwlock_read_lock(&vhost_thread_lock);
> +}
> +
> +void
> +vhost_thread_read_unlock(void)
> +	__rte_no_thread_safety_analysis
> +{
> +	rte_rwlock_read_unlock(&vhost_thread_lock);
> +}
> +
> +void
> +vhost_thread_write_lock(void)
> +	__rte_no_thread_safety_analysis
> +{
> +	rte_rwlock_write_lock(&vhost_thread_lock);
> +}
> +
> +void
> +vhost_thread_write_unlock(void)
> +	__rte_no_thread_safety_analysis
> +{
> +	rte_rwlock_write_unlock(&vhost_thread_lock);
> +}

Looking at the back catalog and spotted this.

What is the reason for moving all the vhost_thread locks into a file?
Also turning off thread safety is a bad idea.
And mixing DPDK locks with pthread mutex is not wise either.

This is not going to be critical path so why not use a pthread_mutex?