From: sashiko-bot@kernel.org
To: "Josh Hilke" <jrhilke@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v11 2/2] vfio: selftests: Find devices that have VFIO selftest drivers
Date: Thu, 03 Dec 2026 23:14:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-248780@kernel.org> (raw)
In-Reply-To: <20261203230106.32033-3-jrhilke@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] vfio: selftests: main() does not reject unexpected positional
arguments
- [Low] vfio: selftests: unchecked sysfs reads reuse stale IDs in
scan_devices()
- [Low] vfio: selftests: unquoted command substitution when sourcing
lib.sh
--
commit 5433f70e41c5fa212afb1ca8022908cf6396102c
Author: Josh Hilke <jrhilke@google.com>
vfio: selftests: Find devices that have VFIO selftest drivers
This commit adds list_supported_devices.sh to scan /sys/bus/pci/devices for
devices supported by VFIO selftest drivers, installs it via the VFIO
selftests Makefile, and documents it in vfio-selftests.rst.
> diff --git a/tools/testing/selftests/vfio/scripts/list_supported_devices.sh b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh
> new file mode 100755
> index 0000000000000..3a3ae152dfcec
> --- /dev/null
> +++ b/tools/testing/selftests/vfio/scripts/list_supported_devices.sh
> @@ -0,0 +1,310 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +source $(dirname -- "${BASH_SOURCE[0]}")/lib.sh
[Severity: Low]
Should this command substitution be quoted as
source "$(dirname -- "${BASH_SOURCE[0]}")/lib.sh"?
When the script lives in a path containing whitespace or glob characters,
word splitting or pathname expansion causes source to fail or load the wrong
file. Because set -e is not enabled, execution continues and
format_device_line() calls the undefined get_driver helper, misreporting
bound devices as unbound.
[ ... ]
> + for bdf in $(ls /sys/bus/pci/devices); do
> + read -r vendor < "/sys/bus/pci/devices/${bdf}/vendor"
> + read -r device < "/sys/bus/pci/devices/${bdf}/device"
> + printf -v id "%04x:%04x" "${vendor}" "${device}"
[Severity: Low]
Can scan_devices() report a removed PCI device using the previous device's
vendor and device IDs?
If a device such as an SR-IOV VF disappears mid-scan, the unchecked input
redirection fails before read runs. vendor and device then keep the prior
iteration's values, causing the vanished BDF to be falsely reported even in
-q output.
Checking the redirections with 2>/dev/null || continue avoids reusing stale
IDs. Similarly, is_nv_gpu() performs an unchecked read on
/sys/bus/pci/devices/${bdf}/class that emits a raw shell error if the device
vanishes mid-scan.
[ ... ]
> + while getopts "qah" opt; do
> + case "${opt}" in
> + q) quiet="true" ;;
> + a) all="true" ;;
> + h) usage; exit 0 ;;
> + \?) usage; exit 1 ;;
> + esac
> + done
> +
> + if [ "${all}" ] && [ -z "${quiet}" ]; then
[Severity: Low]
Does main() silently ignore unexpected positional arguments and any flags
that follow them?
getopts stops parsing at the first non-option argument, so invoking the
script with a BDF like "0000:00:04.0 -q" discards both arguments and prints
verbose output with exit status 0 instead of failing with usage(). Running
shift $((OPTIND - 1)) and rejecting $# -ne 0 would catch stray arguments.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203230106.32033-1-jrhilke@google.com?part=2
prev parent reply other threads:[~2026-12-03 23:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 23:01 [PATCH v11 0/2] vfio: selftests: Find supported devices for testing Josh Hilke
2026-12-03 23:01 ` [PATCH v11 1/2] vfio: selftests: Require -f in setup.sh to unbind a bound device Josh Hilke
2026-12-03 23:01 ` [PATCH v11 2/2] vfio: selftests: Find devices that have VFIO selftest drivers Josh Hilke
2026-12-03 23:14 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-248780@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox