lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQ4LaUi9wTnEN8KA@horms.kernel.org>
Date: Fri, 7 Nov 2025 15:08:25 +0000
From: Simon Horman <horms@...nel.org>
To: Bobby Eshleman <bobbyeshleman@...il.com>
Cc: Stefano Garzarella <sgarzare@...hat.com>, Shuah Khan <shuah@...nel.org>,
	virtualization@...ts.linux.dev, netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
	Bobby Eshleman <bobbyeshleman@...a.com>
Subject: Re: [PATCH net-next v3 04/11] selftests/vsock: avoid multi-VM
 pidfile collisions with QEMU

On Thu, Nov 06, 2025 at 04:49:48PM -0800, Bobby Eshleman wrote:

...

> @@ -90,15 +85,19 @@ vm_ssh() {
>  }
>  
>  cleanup() {
> -	if [[ -s "${QEMU_PIDFILE}" ]]; then
> -		pkill -SIGTERM -F "${QEMU_PIDFILE}" > /dev/null 2>&1
> -	fi
> +	local pidfile
>  
> -	# If failure occurred during or before qemu start up, then we need
> -	# to clean this up ourselves.
> -	if [[ -e "${QEMU_PIDFILE}" ]]; then
> -		rm "${QEMU_PIDFILE}"
> -	fi
> +	for pidfile in "${PIDFILES[@]}"; do
> +		if [[ -s "${pidfile}" ]]; then
> +			pkill -SIGTERM -F "${pidfile}" > /dev/null 2>&1
> +		fi
> +
> +		# If failure occurred during or before qemu start up, then we need
> +		# to clean this up ourselves.
> +		if [[ -e "${pidfile}" ]]; then
> +			rm "${pidfile}"
> +		fi
> +	done
>  }

Hi Bobby,

This is completely untested, but it looks to me
like cleanup() could be implemented more succinctly like this.

cleanup() {
	terminate_pidfiles "${PIDFILES[@]}"
}

>  
>  check_args() {
> @@ -188,10 +187,35 @@ handle_build() {
>  	popd &>/dev/null
>  }
>  
> +create_pidfile() {
> +	local pidfile
> +
> +	pidfile=$(mktemp "${PIDFILE_TEMPLATE}")
> +	PIDFILES+=("${pidfile}")
> +
> +	echo "${pidfile}"
> +}
> +
> +terminate_pidfiles() {
> +	local pidfile
> +
> +	for pidfile in "$@"; do
> +		if [[ -s "${pidfile}" ]]; then
> +			pkill -SIGTERM -F "${pidfile}" > /dev/null 2>&1
> +		fi
> +
> +		if [[ -e "${pidfile}" ]]; then
> +			rm -f "${pidfile}"
> +		fi
> +	done

I think it would be useful to remove $pidfile from $PIDFILES.
This might be easier to implement if PIDFILES was an associative array.

> +}
> +

...

> @@ -498,7 +529,8 @@ handle_build
>  echo "1..${#ARGS[@]}"
>  
>  log_host "Booting up VM"
> -vm_start
> +pidfile="$(create_pidfile)"
> +vm_start "${pidfile}"
>  vm_wait_for_ssh
>  log_host "VM booted up"
>  

> @@ -522,6 +554,8 @@ for arg in "${ARGS[@]}"; do
>  	cnt_total=$(( cnt_total + 1 ))
>  done
>  
> +terminate_pidfiles "${pidfile}"

I am assuming that there will be more calls to terminate_pidfiles
in subsequent patch-sets.

Else I think terminate_pidfiles can be removed
and instead we can rely on cleanup().

> +
>  echo "SUMMARY: PASS=${cnt_pass} SKIP=${cnt_skip} FAIL=${cnt_fail}"
>  echo "Log: ${LOG}"
>  
> 
> -- 
> 2.47.3
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ