All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kenhou Iijima" <kenhou@kenhou.net>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v4] HID: hid-msi: Guard against delayed 0x06 MCU ACKs
Date: Tue, 01 Dec 2026 16:57:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-243764@kernel.org> (raw)
In-Reply-To: <20261201164931.12935-1-kenhou@kenhou.net>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: hid-msi: double volatile jiffies read in
  claw_ack_window_remaining()
--

commit 7768c8b350e8e88673d311b6a516c536e5724746
Author: Kenhou Iijima <kenhou@kenhou.net>

HID: hid-msi: Guard against delayed 0x06 MCU ACKs

This commit restricts generic 0x06 ACK completion to WRITE_PROFILE_DATA
and tracks quiet windows after timeout-0 commands and SYNC_TO_ROM so
delayed ACKs cannot complete subsequent commands early.

> diff --git a/drivers/hid/hid-msi.c b/drivers/hid/hid-msi.c
> index 23d731f700c90..9614f708b14b9 100644
> --- a/drivers/hid/hid-msi.c
> +++ b/drivers/hid/hid-msi.c
[ ... ]
> @@ -486,6 +493,30 @@ static int claw_profile_event(struct claw_drvdata *drvdata, struct claw_command_
>  	return 0;
>  }
>  
> +static unsigned long claw_ack_window_remaining(struct claw_drvdata *drvdata,
> +					       bool *pending, unsigned long until)
> +{
> +	lockdep_assert_held(&drvdata->cmd_lock);
> +
> +	if (!*pending)
> +		return 0;
> +
> +	if (time_before(jiffies, until))
> +		return until - jiffies;
> +
> +	*pending = false;
> +	return 0;
> +}

[Severity: Medium]
Can jiffies advance on another CPU between time_before(jiffies, until) and
until - jiffies?

Because jiffies is volatile, the compiler emits two loads.  If jiffies
reaches until on the second load, claw_ack_window_remaining() returns 0
without clearing *pending; if it advances past until (for example during a
multi-tick NO_HZ catchup or vCPU preemption), until - jiffies underflows
and causes __claw_hw_output_report() or claw_hw_output_report() to sleep
for a huge timeout while holding cfg_mutex or rom_mutex.  Snapshotting
jiffies into a local variable once avoids both.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201164931.12935-1-kenhou@kenhou.net?part=1

      reply	other threads:[~2026-12-01 16:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:49 [PATCH v4] HID: hid-msi: Guard against delayed 0x06 MCU ACKs Kenhou Iijima
2026-12-01 16:57 ` 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-243764@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kenhou@kenhou.net \
    --cc=linux-input@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 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.