From: sashiko-bot@kernel.org
To: "Myeonghun Pak" <mhun512@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
Date: Sun, 11 Oct 2026 22:21:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-167476@kernel.org> (raw)
In-Reply-To: <20261011220531.2073892-2-mhun512@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] hid: intel-thc-hid: DMA UAF due to HID deregistration race in remove
--
commit 664b72e58bd5cb1485c8eb563326dab08180f916
Author: Myeonghun Pak <mhun512@gmail.com>
HID: intel-thc-hid: quickspi: quiesce IRQs during teardown
This commit disables and synchronizes the IRQ and drains recovery work prior
to freeing the IRQ and releasing HID/DMA resources. It introduces this ordered
teardown in both the probe error and remove paths.
Link: https://lore-kernel.gnuweeb.org/linux-input/20260717035609.3874015-1-even.xu@intel.com/T/
Link: https://patchew.org/linux/20260729050145.2272597-1-even.xu@intel.com/
> diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
> index 53023e30cf8d4..c67476a378573 100644
> --- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
> +++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
[ ... ]
> @@ -721,9 +731,12 @@ static void quickspi_remove(struct pci_dev *pdev)
> if (!qsdev)
> return;
>
> - quickspi_hid_remove(qsdev);
> -
> + WRITE_ONCE(qsdev->recovery_disabled, true);
> + disable_irq(pdev->irq);
> quickspi_dev_deinit(qsdev);
> + devm_free_irq(&pdev->dev, pdev->irq, qsdev);
> +
> + quickspi_hid_remove(qsdev);
[Severity: High]
Does this sequence open a race window for a hardware DMA use-after-free?
By tearing down the hardware and disabling interrupts before unregistering the
HID device, it appears userspace can still issue a request via hidraw during
unbind.
If a raw_request is queued on the disabled device, it may call thc_dma_write()
to submit a TxDMA request:
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:thc_dma_write() {
...
ret = wait_event_interruptible_timeout(dev->write_complete_wait, dev->write_done, 1 * HZ);
if (ret <= 0 || !dev->write_done) {
dev_err_once(dev->dev, "timeout for waiting TxDMA completion\n");
ret = -ETIMEDOUT;
goto end;
}
...
}
Because IRQs are disabled here, the wait will time out and return -ETIMEDOUT,
but it fails to clear the TxDMA START bit.
quickspi_remove() will then proceed to unregister the HID device and call
quickspi_dma_deinit(), which frees the DMA buffers without clearing the TxDMA
START bit. Could this allow the hardware TxDMA engine to remain active and
access freed DMA memory, leading to memory corruption or an IOMMU fault?
Note that follow-up patches in the series do not appear to resolve this race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261011220531.2073892-1-mhun512@gmail.com?part=1
next prev parent reply other threads:[~2026-10-11 22:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 22:05 [PATCH 0/2] HID: intel-thc-hid: quiesce interrupts before final teardown Myeonghun Pak
2026-10-11 22:05 ` [PATCH 1/2] HID: intel-thc-hid: quickspi: quiesce IRQs during teardown Myeonghun Pak
2026-10-11 22:21 ` sashiko-bot [this message]
2026-10-13 0:52 ` Xu, Even
2026-10-11 22:05 ` [PATCH 2/2] HID: intel-thc-hid: quicki2c: " Myeonghun Pak
2026-10-11 22:20 ` sashiko-bot
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-167476@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=mhun512@gmail.com \
--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