From: Niklas Cassel <cassel@kernel.org>
To: Hyunjung Ko <hj351016@gmail.com>
Cc: Damien Le Moal <dlemoal@kernel.org>, linux-ide@vger.kernel.org
Subject: Re: [PATCH v3] ata: libahci: delete the SW activity blink timer on port stop
Date: Tue, 10 Nov 2026 11:27:30 +0100 [thread overview]
Message-ID: <avLxkrcgP97hiUV1@ryzen> (raw)
In-Reply-To: <20261110090303.2415681-1-hj351016@gmail.com>
On Tue, Nov 10, 2026 at 06:03:03PM +0900, Hyunjung Ko wrote:
> The software activity LED support arms a per-EM-port timer (emp->timer,
> ahci_sw_activity_blink) from ahci_sw_activity() on I/O, and the timer
> callback re-arms itself while the LED is blinking. The timer lives in
> struct ahci_em_priv inside the port's ahci_port_priv, which is allocated
> with devm_kzalloc() and freed when the port is torn down.
>
> ahci_port_stop() never deletes this timer - nothing in libahci does - so
> when the SW activity LED is in use and the AHCI port is stopped (driver
> unbind / module unload) while the blink timer is still pending,
> ahci_sw_activity_blink() runs after ahci_port_priv has been freed and
> dereferences the freed ahci_em_priv (use-after-free).
>
> Shut the timers down in ahci_port_stop() before the port private data is
> released, only when ATA_FLAG_SW_ACTIVITY is set and skipping em_priv slots
> that ahci_init_sw_activity() never set up. Because the callback re-arms
> itself, use timer_shutdown_sync() so a concurrent re-arm cannot resurrect
> it.
>
> Not tested on real hardware (needs an AHCI controller with SGPIO
> enclosure management and the software activity LED enabled).
>
> Fixes: 365cfa1ed5a3 ("ahci: Move generic code into libahci")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
> ---
> Changes in v3:
> - Shorten the code comment (Niklas Cassel).
It seems like you modified v1 instead of v2.
v3's index line is 001a6f5..873645c, exactly v1's. Applying v3
to blob 001a6f5 actually produces ace66cd, so the patch was most
likely hand-edited from v1 rather than regenerated.
Please use git format-patch.
Kind regards,
Niklas
prev parent reply other threads:[~2026-11-10 10:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 9:03 [PATCH v3] ata: libahci: delete the SW activity blink timer on port stop Hyunjung Ko
2026-11-10 9:25 ` sashiko-bot
2026-11-10 10:27 ` Niklas Cassel [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=avLxkrcgP97hiUV1@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hj351016@gmail.com \
--cc=linux-ide@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox