๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Sun, 29 Nov 2026 10:38
Re: [PATCH net-next v5 02/14] selftests: dpll: add test library and device lifecycle tests
#24122
Author: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 10:38
119 lines
12247 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Signal race in dpllsim_create_device()
  (tools/testing/selftests/drivers/dpll/dpll_lib.sh) that can make a runโ€ฆ

--

selftests: dpll: add test library and device lifecycle tests

This adds a shell library for the DPLL selftests. It wraps the iproute2
dpll tool and the dpllsim configfs interface. It also adds two scripts:
dpll_basic.sh checks the mandatory device attributes over netlink, and
dpll_stress.sh repeatedly creates, deploys and deletes dpllsim devices.

> diff --git a/tools/testing/selftests/drivers/dpll/dpll_lib.sh b/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> new file mode 100644
> index 0000000000000..467527a4343af
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> @@ -0,0 +1,446 @@

[ ... ]

> +dpllsim_create_device()
> +{
> +	local name=$1
> +	local clock_id=$2
> +	local dev_path="$DPLLSIM_CFG/$name"
> +
> +	# A directory of that name was left behind by something else and
> +	# must never be recorded as a device of this run.
> +	[ -e "$dev_path" ] && return 1
> +
> +	# Record the name before the directory exists, so that a cleanup
> +	# run by a signal between the two still finds it.
> +	DPLLSIM_CREATED_NAME=$name
> +	if ! mkdir "$dev_path" 2>/dev/null; then
> +		DPLLSIM_CREATED_NAME=""
> +		return 1
> +	fi

[Severity: Low]
Can the cleanup handler end up deleting a dpllsim device that this run
did not create?

The flock in dpll_lib_lock() only serializes the scripts in this
directory. Other users of the shared dpllsim configfs directory are not
serialized by it. Examples are a root user working by hand, or a run in
a container that has its own /run but shares the global configfs.

Suppose such a user creates a directory with the same name between the
[ -e "$dev_path" ] check and the mkdir. The mkdir then fails with EEXIST.
DPLLSIM_CREATED_NAME still holds the name in two windows:

  - between the assignment and the mkdir
  - after the failed mkdir returns, before DPLLSIM_CREATED_NAME=""

bash runs a pending INT or TERM trap as soon as the foreground command
finishes. A harness timeout or Ctrl-C in either window runs the trap
below, and the trap exits before the reset happens:

  trap 'trap "" INT TERM; trap - EXIT; cleanup; exit 1' INT TERM

[ ... ]

> diff --git a/tools/testing/selftests/drivers/dpll/dpll_stress.sh b/tools/testing/selftests/drivers/dpll/dpll_stress.sh
> new file mode 100755
> index 0000000000000..2c60ac9faefda
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/dpll/dpll_stress.sh
> @@ -0,0 +1,201 @@

[ ... ]

> +cleanup()
> +{
> +	# A second signal must not abort the teardown half way.
> +	trap '' INT TERM
> +
> +	local dev
> +
> +	for dev in "${CREATED_DEVICES[@]}"; do
> +		dpllsim_delete_device "$dev" ||
> +			log_info "cannot delete device $dev"
> +	done
> +	# The device whose creation a signal interrupted is recorded by the
> +	# library alone, a double delete of a tracked one is harmless.
> +	if [ -n "$DPLLSIM_CREATED_NAME" ]; then
> +		dpllsim_delete_device "$DPLLSIM_CREATED_NAME" ||
> +			log_info "cannot delete device $DPLLSIM_CREATED_NAME"
> +	fi
> +	dpll_lib_cleanup
> +}

[Severity: Low]
In that case, dpllsim_delete_device() here finds the other user's
directory and writes 0 to its live attribute. That unregisters the device
from the DPLL core, and the directory is then removed with rmdir.

cleanup() in dpll_basic.sh does the same, reached through
dpllsim_setup_standard_device()->dpllsim_create_device().

The v4 changelog says a directory that existed before must never be
recorded as a device of the run. Doesn't recording the name before an
mkdir that can fail leave a window where the record points at a directory
this run did not create?

The window is narrow. It needs another root user to create the exact
std/st/cycle name that was just picked, and a signal at the same moment.

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125090522.3777494-1-poros%40redhat.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads