All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sean Young" <sean@mess.org>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 4/7] media: sunxi-cir: Ensure no more interrupts can occur before free
Date: Fri, 10 Jul 2026 09:03:19 +0000	[thread overview]
Message-ID: <20260710090319.8B85C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <e74a0caf91aaefaf98476a191e6489c606632bf1.1783673420.git.sean@mess.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch fails to fix the IRQ Use-After-Free race condition and exacerbates a bus fault vulnerability by disabling hardware clocks without synchronizing the devm-managed interrupt.
- [High] The interrupt is requested before the hardware is initialized in the probe function, leading to a possible bus fault on spurious interrupts and a Use-After-Free in the error path.
--

--- Patch [4]: [PATCH 4/7] media: sunxi-cir: Ensure no more interrupts can occur before free ---
commit 8ac4bdb72847c70ea6f26a6012ec7552bc70de07
Author: Sean Young <sean@mess.org>

media: sunxi-cir: Ensure no more interrupts can occur before free

This commit reorders the device removal sequence to call rc_free_device()
only after the hardware has been stopped via sunxi_ir_hw_exit(). The stated
intent is to prevent interrupts from occurring after the device is freed.

> diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
> index 28e840a7e5b8c..af1ee08ffdbec 100644
> --- a/drivers/media/rc/sunxi-cir.c
> +++ b/drivers/media/rc/sunxi-cir.c
> @@ -374,8 +374,8 @@ static void sunxi_ir_remove(struct platform_device *pdev)
>  	struct sunxi_ir *ir = platform_get_drvdata(pdev);
>  
>  	rc_unregister_device(ir->rc);
> -	rc_free_device(ir->rc);
>  	sunxi_ir_hw_exit(&pdev->dev);
> +	rc_free_device(ir->rc);

[Severity: High]
This is a pre-existing issue, but does this sequence completely prevent
interrupts from occurring before the free?

Because the interrupt is managed by devm_request_irq(), it remains active
until devres cleanup runs after sunxi_ir_remove() completes. Since
sunxi_ir_hw_exit() only disables clocks, if a pending or spurious interrupt
fires afterward, sunxi_ir_irq() will access unclocked memory-mapped registers
and trigger a bus fault.

Additionally, if the interrupt handler runs concurrently on another processor:

sunxi_ir_irq()
    ir_raw_event_overflow(ir->rc);

could it access ir->rc after it is freed by rc_free_device() here, since
there is no synchronize_irq() or disable_irq() in sunxi_ir_remove()?

[Severity: High]
This is also a pre-existing issue, but does sunxi_ir_probe() suffer from a
similar race condition?

In sunxi_ir_probe(), devm_request_irq() is called to unmask the interrupt
before sunxi_ir_hw_init() enables the clock. If a pending interrupt from
a previous boot or a spurious interrupt fires during this window,
sunxi_ir_irq() will execute before the clock is enabled, potentially causing
a bus fault.

Also, if sunxi_ir_hw_init() fails, the error path eventually calls
rc_free_device() without explicitly disabling the active interrupt, which
leaves a window for a use-after-free on ir->rc.

>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783673420.git.sean@mess.org?part=4

  reply	other threads:[~2026-07-10  9:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10  8:53 [PATCH 0/7] Fix leaks in rc core Sean Young
2026-07-10  8:53 ` [PATCH 1/7] media: streamzap: Add missing rc_unregister_device() Sean Young
2026-07-10  8:53 ` [PATCH 2/7] media: redrat3: Ensure rc device is freed if enable_detector() fails Sean Young
2026-07-10  8:53 ` [PATCH 3/7] media: redrat3: Ensure we don't read beyond the end of the packet Sean Young
2026-07-10  8:53 ` [PATCH 4/7] media: sunxi-cir: Ensure no more interrupts can occur before free Sean Young
2026-07-10  9:03   ` sashiko-bot [this message]
2026-07-10  8:53 ` [PATCH 5/7] media: meson-ir-tx: Ensure clock is disabled on unbind Sean Young
2026-07-10  8:53   ` Sean Young
2026-07-10  9:05   ` sashiko-bot
2026-07-12 13:26   ` Martin Blumenstingl
2026-07-12 13:26     ` Martin Blumenstingl
2026-07-10  8:53 ` [PATCH 6/7] media: meson-ir-tx: Ensure rc_free_device() is called " Sean Young
2026-07-10  8:53   ` Sean Young
2026-07-12 13:23   ` Martin Blumenstingl
2026-07-12 13:23     ` Martin Blumenstingl
2026-07-10  8:53 ` [PATCH 7/7] media: ir-hix5hd2: Ensure rdev is setup before interrupts are enabled Sean Young

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=20260710090319.8B85C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sean@mess.org \
    /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.