Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] After a device has been removed, its name stays recorded in
DPLLSIM_CREATED_NAME, and the exit cleanup deletes whatever directory…
- [Low] The header of tools/testing/selftests/drivers/dpll/dpll_stress.sh
(lines 4-5) says "Uses dpllsim to put the DPLL core under load, the…
- [Low] dpll_lib_run_dir() in
tools/testing/selftests/drivers/dpll/dpll_lib.sh (lines 70-72) makes…
--
selftests: dpll: add test library and device lifecycle tests
This adds a shell library for DPLL selftests. It wraps the iproute2 dpll
tool and the dpllsim configfs interface, and the patch adds two scripts
built on it. dpll_basic.sh checks the mandatory netlink attributes of a
hardware or simulated device. dpll_stress.sh drives dpllsim devices
through repeated create/delete and register/unregister cycles.
> 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..0b75220d7d0bc
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> @@ -0,0 +1,448 @@
[ ... ]
> +# Create DPLL_RUN_DIR private when it is missing and make an existing
> +# one private too, whatever the umask, others that can write to it
> +# could plant a symlink in place of the lock file. Skip when that fails.
> +dpll_lib_run_dir()
> +{
> + mkdir -m 0700 "$DPLL_RUN_DIR" 2>/dev/null
> + if ! [ -d "$DPLL_RUN_DIR" ] ||
> + ! chmod 0700 "$DPLL_RUN_DIR" 2>/dev/null; then
> + echo "SKIP: cannot set up $DPLL_RUN_DIR"
> + exit "$ksft_skip"
> + fi
> +}
> +
> +dpll_lib_lock()
> +{
> + if ! command -v flock &> /dev/null; then
> + echo "SKIP: flock not found"
> + exit "$ksft_skip"
> + fi
> + dpll_lib_run_dir
> + # A redirection that fails makes exec return non-zero here, bash
> + # exits the shell for it only in POSIX mode.
> + if ! { exec {DPLL_LOCK_FD}> "$DPLL_LOCK_FILE"; } 2>/dev/null; then
[Severity: Low]
Does dpll_lib_run_dir() fully provide the protection the commit message
describes?
"Its directory is made private whatever the umask, for the same reason."
mkdir -m 0700 sets the mode atomically only when it creates the directory.
If /run/dpll-selftest already exists, the code falls through to [ -d ] and
chmod 0700. Both of those follow symlinks, and neither checks the owner.
If the existing directory belongs to a non-root user, chmod 0700 leaves
that owner with write access. The owner can then replace lock with a
symlink, and the truncating redirection in dpll_lib_lock() opens it as
root and truncates the target.
If /run/dpll-selftest is itself a symlink to a directory, chmod changes
the mode of the target, and the lock file is opened inside it.
/run is normally root:root 0755, so only a privileged process could set
this up.
Would a check such as [ ! -L "$DPLL_RUN_DIR" ] && [ -O "$DPLL_RUN_DIR" ],
plus opening the lock file with >> or <> instead of >, close this? The
code is the same at the end of the series, where this directory also
holds the ref_tracker snapshot files.
> + echo "SKIP: cannot open $DPLL_LOCK_FILE"
> + exit "$ksft_skip"
> + fi
[ ... ]
> +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
> +
> + if ! mkdir "$dev_path" 2>/dev/null; then
> + return 1
> + fi
[ ... ]
> + DPLLSIM_CREATED_NAME=$name
> + if ! echo "$clock_id" 2>/dev/null > "$dev_path/clock_id"; then
> + rmdir "$dev_path" 2>/dev/null && DPLLSIM_CREATED_NAME=""
> + return 1
> + fi
> +}
[ ... ]
> +dpllsim_delete_device()
> +{
> + local dev_path="$DPLLSIM_CFG/$1"
> + local ret=0
> +
> + [ -d "$dev_path" ] || return 0
> +
> + dpllsim_undeploy "$1" || ret=1
> + rmdir "$dev_path" || ret=1
> +
> + return "$ret"
> +}
[Severity: Medium]
Is DPLLSIM_CREATED_NAME left stale once the device it names is gone?
dpllsim_delete_device() removes the directory but leaves the record
alone. dpllsim_create_device() only clears it on the failed clock_id
write path.
None of the callers clear it after a successful delete either:
test_rapid_create_delete() and test_deploy_cycle() only call
untrack_device "$name".
create_stress_device() deletes on a deploy failure and returns.
dpllsim_setup_standard_device() deletes on a deploy or netlink wait
failure and returns 1.
The early returns in dpllsim_create_device() (the [ -e ] check and a
failed mkdir) also leave the previous, already deleted name in place.
Both cleanup() handlers then run:
tools/testing/selftests/drivers/dpll/dpll_stress.sh:cleanup() {
...
if [ -n "$DPLLSIM_CREATED_NAME" ]; then
dpllsim_delete_device "$DPLLSIM_CREATED_NAME" ||
log_info "cannot delete device $DPLLSIM_CREATED_NAME"
fi
...
}
dpll_basic.sh has the same lines. dpllsim_delete_device() checks only
[ -d ] before it writes 0 to live and calls rmdir.
After test_rapid_create_delete() ends, the record names the last
"st<clock-id>" device for the rest of the run. Suppose something outside
this run creates a dpllsim item with that name before exit. Would
cleanup() then undeploy and remove it? The lock file only keeps out
other dpll selftest runs. This looks the same at the end of the series,
where more tests run between the first test and the cleanup at exit.
The commit message says:
"A device name is recorded only once its directory exists, so that the
cleanup cannot remove a directory another user created in between."
The cleanup comment also says "a double delete of a tracked one is
harmless". Both seem to hold only while the directory still belongs to
this run.
Could dpllsim_delete_device() clear DPLLSIM_CREATED_NAME when it removes
that name, or could the callers clear it after a successful delete?
> 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 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# DPLL subsystem stress test. Uses dpllsim to put the DPLL core under
> +# load, the tests below say what each of them exercises.
[Severity: Low]
This isn't a bug, but neither test has the description this header
points to. test_rapid_create_delete() has no comment. The only comment
in test_deploy_cycle() explains why the busywait timeouts cannot add up,
not what the test exercises.
The same holds at the end of the series for test_rapid_create_delete,
test_pin_state_flooding and test_many_devices.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40redhat.com