From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 403133AA4E9 for ; Fri, 10 Apr 2026 08:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775809994; cv=none; b=sA0k7KemPdO3u/4E0gCFsFGHRMvLz3T1V5tNTk2QdufJJR5M3OoK4xbgQBfzyFLqX4vNcjG5jVJoCKjIUQhZxYoDwD85OKVrSUzcgwCo+EmPUkP6ojsFlhIu4cPdwObDRJAte59wF3UmqvCdK0Jcm81b+ygzQK3TLBYH57qajeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775809994; c=relaxed/simple; bh=3P3Yp7kZAgzbJGxtHzxC2EX0OREVvZPZwUK5CbfY+SQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AJP+cwy/zy0p27VsxE7GExRBbbxvulk6/lUR/UpRgXUWkFdVUPa1DSDd8nHFz7px26YUlHQ+qXo/mkSEBTWiMOA4KaBELk0eDzuaUn9hU5b1+ThiSU8tKabmSLyLcZEXGPV+Wf35DoqRrWg3KXBpWCeocMdVAMob0Kcb4YNNGBI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fPforsnt; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=UrtQaKx7; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fPforsnt"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="UrtQaKx7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775809992; 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: in-reply-to:in-reply-to:references:references; bh=AbV+a2kN0fqhbaSyrzX6IchPn1p4RqFKSu0TwhqfCNk=; b=fPforsnt59zTHBdttNhLSDdxbOPJT8CRKjJ84+IXitog8SrX+RueEIJb+P3DuVU18uUjlG fgs23/uaYwcWv8z+xE7r4841vzUYTfVUsKNiXL7gXs/M7HmKQzStpEWwmbxkvLeOczmR71 as6SHrjhhfPbwUVGkaoZvoG09tQLiGk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-308-7D79HRfrMnq2fPiAXZOn1g-1; Fri, 10 Apr 2026 04:33:09 -0400 X-MC-Unique: 7D79HRfrMnq2fPiAXZOn1g-1 X-Mimecast-MFC-AGG-ID: 7D79HRfrMnq2fPiAXZOn1g_1775809988 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-488ac66236bso11039615e9.1 for ; Fri, 10 Apr 2026 01:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775809988; x=1776414788; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AbV+a2kN0fqhbaSyrzX6IchPn1p4RqFKSu0TwhqfCNk=; b=UrtQaKx7UDHS0qzc2oIghv70modh1UUgsZ9y2ulbSGDwsolLOusN4l0t55GLna/c7x xgcvb0hfG4ZrXvc4ENx12Vy2bwA/nsA7/tJc1qBbBJYZg6tPp73jHgfiWMS8SbIxLiAf U8jXbb89uAjigiORrXkx4mVkvDLGHDk+Em7rjpMvWeTlDddu7Ug0PY8sKjbieRqWkBPN OWthFcVKSGZrrwkvX1oFixjQ2yrNyAcHn50riRgqyxx/Ijcv56FgvKFQxbRH0QPHaHFo etZbDA76EPr3MkOjbLk6CwpmJlcERY/PuPgTsI//XIxe5rg3Fxv6EFsdxUiA5cdqupWv g87A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775809988; x=1776414788; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AbV+a2kN0fqhbaSyrzX6IchPn1p4RqFKSu0TwhqfCNk=; b=s8BEKMI2LnAN9GZ3Fo3ttRAxNfqlcS332yjb94StRJ+a+QZ/PtuVJmTk/vN05ihVhF ERWjpqNrfW44hHVL3b0QzM3Q4WQnJ3AytP5YZ/Q63OHB2zfzroRVnuSFAQpgLlDVC4AK Hl8ITQE8j+wVbJ5nHFxdw0jtJ1s7fEY6e6HfZw429xiwObAm52jnp8+6PeELPLR1xo+2 fP4ueTN0jmSh/q5SOltG3E7nsGnGOwNA9ZEbq80Fto+Kzj7od3cazwaT2UP4BT6UgES0 HaUcAX8DFC/52se7+SgkAm3EFuHx8ewWVwQTHF3MveWYy8r3Oc9Rd1EkTQ5M2QklHmAA vlwQ== X-Forwarded-Encrypted: i=1; AJvYcCWQ/8XTCbEAWd6oJWwDr8JMhsv/ePYJLEWpcNiBiaYAE3Y3Q+xCmausJm/BxVvyGPtKlAqACnpCwkUYW/c=@vger.kernel.org X-Gm-Message-State: AOJu0YxWJDMWlEc8wDArVR1D6JIdXIRDebckygjpMk5DtbQmp0UCDGx0 C70TZYgINKwGNLDpQhViLL5h/5BGdEy3UW1nnFjaLLGxOkre47BckYfHL8ANaVUzdgdwjBpY29f /JX8SLGtDP5nUJeTJNw0PMvdJnZ3OLKT8uE3LRND7yjKKanchvJlF4M+iZ7i6aVpotA== X-Gm-Gg: AeBDiet/b2gxRs9lb5nmWwkzEhH+un/I3CiqtPEG/Q8cf4Z/gzHccWarFF63TcdLnlj OcAi+/cDeByWMtWa4CTorbO8ZvLnLxt5YvwXTq7lC9gxcH/SJmJKY7kv0+l4AVDgIxvATnMc5Dh DbNVi5tsxeEd/TyQXwlEzZi1vEoJgF1lhpPR/wBnn7WGIfyxMKZ3iHdu3HM0lL8AhLb7w0Wf+Zd TRizliDZdjvkS7UVw+FnqGxwpEI7BVaAf76HRkztkB00NP8cB0eHhAQ3BkWYfBjMRbED/9gJy0q GWVadBD4VCJlo7RkyX982NZVuOVNxAYoTgpN4yOitRjDH2lMrwBEMkPDECfCNtfqq4KlRMSC0ZZ n0G9DqWkNIGHnM8r8kXi9CuU2SMaVWHWlybIhCZZvg8ZckXoLYPapx59hFOFMryqExSzKN32J7g == X-Received: by 2002:a05:600c:c10c:b0:486:faa8:9e4 with SMTP id 5b1f17b1804b1-488d68cb8demr15409415e9.12.1775809988185; Fri, 10 Apr 2026 01:33:08 -0700 (PDT) X-Received: by 2002:a05:600c:c10c:b0:486:faa8:9e4 with SMTP id 5b1f17b1804b1-488d68cb8demr15409165e9.12.1775809987691; Fri, 10 Apr 2026 01:33:07 -0700 (PDT) Received: from sgarzare-redhat (host-79-45-205-236.retail.telecomitalia.it. [79.45.205.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d5b3c597sm53013275e9.12.2026.04.10.01.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 01:33:07 -0700 (PDT) Date: Fri, 10 Apr 2026 10:33:01 +0200 From: Stefano Garzarella To: Cao Ruichuang Cc: stefano.garzarella@gmail.com, shuah@kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org Subject: Re: [PATCH v2] selftests: vsock: avoid races creating Unix socket paths Message-ID: References: <20260405195733.86043-1-create0818@163.com> <20260410035237.59644-1-create0818@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20260410035237.59644-1-create0818@163.com> On Fri, Apr 10, 2026 at 11:52:37AM +0800, Cao Ruichuang wrote: No patch description at all? >Signed-off-by: Cao Ruichuang >--- >v2: >- retitle the patch to describe the race being fixed >- replace rm -rf with explicit rm and rmdir cleanup > > tools/testing/selftests/vsock/vmtest.sh | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > >diff --git a/tools/testing/selftests/vsock/vmtest.sh b/tools/testing/selftests/vsock/vmtest.sh >index 86e338886b3..c345fa539d3 100755 >--- a/tools/testing/selftests/vsock/vmtest.sh >+++ b/tools/testing/selftests/vsock/vmtest.sh >@@ -718,6 +718,7 @@ test_ns_diff_global_host_connect_to_global_vm_ok() { > local pids pid pidfile > local ns0 ns1 port > declare -a pids >+ local unixdir > local unixfile > ns0="global0" > ns1="global1" >@@ -736,7 +737,8 @@ test_ns_diff_global_host_connect_to_global_vm_ok() { > oops_before=$(vm_dmesg_oops_count "${ns0}") > warn_before=$(vm_dmesg_warn_count "${ns0}") > >- unixfile=$(mktemp -u /tmp/XXXX.sock) >+ unixdir=$(mktemp -d /tmp/vsock_vmtest_XXXXXX) >+ unixfile="${unixdir}/sock" > ip netns exec "${ns1}" \ > socat TCP-LISTEN:"${TEST_HOST_PORT}",fork \ > UNIX-CONNECT:"${unixfile}" & >@@ -758,6 +760,8 @@ test_ns_diff_global_host_connect_to_global_vm_ok() { > > terminate_pids "${pids[@]}" > terminate_pidfiles "${pidfile}" >+ rm "${unixfile}" >+ rmdir "${unixdir}" > > if [[ "${rc}" -ne 0 ]] || [[ "${dmesg_rc}" -ne 0 ]]; then > return "${KSFT_FAIL}" >@@ -814,6 +818,7 @@ test_ns_diff_global_vm_connect_to_global_host_ok() { > local ns0="global0" > local ns1="global1" > local port=12345 >+ local unixdir > local unixfile > local dmesg_rc > local pidfile >@@ -826,7 +831,8 @@ test_ns_diff_global_vm_connect_to_global_host_ok() { > > log_host "Setup socat bridge from ns ${ns0} to ns ${ns1} over port ${port}" > >- unixfile=$(mktemp -u /tmp/XXXX.sock) >+ unixdir=$(mktemp -d /tmp/vsock_vmtest_XXXXXX) >+ unixfile="${unixdir}/sock" > > ip netns exec "${ns0}" \ > socat TCP-LISTEN:"${port}" UNIX-CONNECT:"${unixfile}" & >@@ -845,7 +851,8 @@ test_ns_diff_global_vm_connect_to_global_host_ok() { > if ! vm_start "${pidfile}" "${ns0}"; then > log_host "failed to start vm (cid=${cid}, ns=${ns0})" > terminate_pids "${pids[@]}" >- rm -f "${unixfile}" >+ rm "${unixfile}" >+ rmdir "${unixdir}" > return "${KSFT_FAIL}" > fi > >@@ -862,7 +869,8 @@ test_ns_diff_global_vm_connect_to_global_host_ok() { > > terminate_pidfiles "${pidfile}" > terminate_pids "${pids[@]}" >- rm -f "${unixfile}" >+ rm "${unixfile}" >+ rmdir "${unixdir}" > > if [[ "${rc}" -ne 0 ]] || [[ "${dmesg_rc}" -ne 0 ]]; then > return "${KSFT_FAIL}" >-- >2.39.5 (Apple Git-154) > >