All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mike Lothian" <mike@fireburn.co.uk>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 10/13] drm/vino: read the dock's firmware version, and update it over DFU
Date: Wed, 26 Aug 2026 16:58:55 +0000	[thread overview]
Message-ID: <20260826165856.0494E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260826163913.7052-11-mike@fireburn.co.uk>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The automatic update path in `update_if_newer` fails to verify that the firmware package matches the dock's hardware family, allowing a mismatched firmware file to permanently brick the dock.
- [Medium] Infinite update loop and data race due to a single shared non-atomic rate-limit slot (`UPDATE_ATTEMPTS`).
--

commit 872c2fc3f8d6d143ff1f9c6026fbab419e5a21e3
Author: Mike Lothian <mike@fireburn.co.uk>
Subject: drm/vino: read the dock's firmware version, and update it over DFU

A DisplayLink dock does not advance bcdDevice when its firmware changes. This
patch adds parsers for the dock's identity descriptor and shipped firmware
package, and applies updates automatically over USB DFU if the packaged
version is strictly newer. It also provides a manual upload interface.

> diff --git a/drivers/gpu/drm/vino/firmware.rs b/drivers/gpu/drm/vino/firmware.rs
> new file mode 100644
> index 0000000000000..13c9cff55ae48
> --- /dev/null
> +++ b/drivers/gpu/drm/vino/firmware.rs
[ ... ]
> +fn claim_update_attempt(dev: &Device) -> bool {
> +    let key = attempt_key(dev);
> +    let slot = UPDATE_ATTEMPTS.load(Ordering::Acquire);
> +    let count = if slot & ATTEMPT_KEY_MASK == key {
> +        slot as u32
> +    } else {
> +        0
> +    };
> +    if count >= MAX_UPDATE_ATTEMPTS {
> +        return false;
> +    }
> +    UPDATE_ATTEMPTS.store(key | u64::from(count + 1), Ordering::Release);
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Medium]
Could this non-atomic read-modify-write on the shared global UPDATE_ATTEMPTS
variable cause an infinite update loop?

If two docks are connected that require an update, and both fail to apply it
successfully, they might re-enumerate and probe continuously. Because
claim_update_attempt() loads and then stores on a single global slot, it looks
like the two docks might continuously evict each other's attempt counts.

This could prevent either dock from reaching MAX_UPDATE_ATTEMPTS to break
the loop, which might lead to constant USB bus resets and flash memory wear-out.

Similarly, clear_update_attempts() performs a non-atomic check-and-clear
that might race with this logic and clear another device's freshly recorded
attempts:

    if UPDATE_ATTEMPTS.load(Ordering::Acquire) & ATTEMPT_KEY_MASK == key {
        UPDATE_ATTEMPTS.store(0, Ordering::Release);
    }

[ ... ]
> +pub(crate) fn update_if_newer(
> +    io: &usb::Io<'_>,
> +    dev: &Device,
> +    identity: &Identity,
> +    iface: u16,
> +    force: bool,
> +) -> Result {
[ ... ]
> +    let Some(packaged) = package_version(fw.data()) else {
> +        dev_warn!(dev, "{} carries no version tag; ignoring it\n", name);
> +        return Ok(());
> +    };
> +    if packaged <= identity.version && !force {
> +        clear_update_attempts(dev);
> +        vino_dev_debug!(dev, "firmware is current ({} offers {})\n", name, packaged);
> +        return Ok(());
> +    }
[ ... ]
> +    dev_info!(
> +        dev,
> +        "updating dock firmware {} -> {}{}\n",
> +        identity.version,
> +        packaged,
> +        if force { " (forced)" } else { "" }
> +    );
> +    flash(io, iface, fw.data())
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
Should this automatic update path verify that the firmware package matches
the dock's hardware family before flashing?

The manual upload path (Upload::prepare) uses package_family(image) and
refuses to flash if the family does not match the hardware. However,
update_if_newer() only checks the version and relies on the filename.

If a mismatched firmware file is inadvertently placed in /lib/firmware/vino/,
it appears this would silently flash the incompatible image and permanently
render the dock unusable, circumventing the safety check implemented for
manual uploads.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260826163913.7052-1-mike@fireburn.co.uk?part=10

  reply	other threads:[~2026-08-26 16:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 16:37 [PATCH v3 0/13] drm/vino: a Rust driver for DisplayLink DL3 docks Mike Lothian
2026-08-26 16:37 ` [PATCH v3 1/13] drm/vino: add the DL3 wire framing Mike Lothian
2026-08-26 16:37 ` [PATCH v3 2/13] drm/vino: add the USB transport Mike Lothian
2026-08-26 16:58   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 3/13] drm/vino: add the crypto primitives and the HDCP 2.2 AKE Mike Lothian
2026-08-26 16:37 ` [PATCH v3 4/13] drm/vino: add the encrypted control plane Mike Lothian
2026-08-26 16:37 ` [PATCH v3 5/13] drm/vino: add the dock profiles Mike Lothian
2026-08-26 16:37 ` [PATCH v3 6/13] drm/vino: add the video codec Mike Lothian
2026-08-26 16:56   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 7/13] drm/vino: add control-session bring-up Mike Lothian
2026-08-26 16:57   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 8/13] drm/vino: add the KMS device and the atomic path Mike Lothian
2026-08-26 16:59   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 9/13] drm/vino: add the dock activation and scanout path Mike Lothian
2026-08-26 16:59   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 10/13] drm/vino: read the dock's firmware version, and update it over DFU Mike Lothian
2026-08-26 16:58   ` sashiko-bot [this message]
2026-08-26 16:37 ` [PATCH v3 11/13] drm/vino: add the USB driver frontend Mike Lothian
2026-08-26 17:01   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 12/13] drm/vino: allow the driver to be built Mike Lothian
2026-08-26 17:04   ` sashiko-bot
2026-08-26 16:37 ` [PATCH v3 13/13] Documentation/gpu: document the Vino driver Mike Lothian
2026-08-26 17:10   ` sashiko-bot
2026-08-26 17:28   ` Randy Dunlap

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=20260826165856.0494E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mike@fireburn.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.