All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: hyunjungg <hj351016@gmail.com>, linux-rtc@vger.kernel.org
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH] rtc: atcrtc100: drain the alarm work before the RTC device is freed
Date: Sat, 07 Nov 2026 06:46:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-202667@kernel.org> (raw)
In-Reply-To: <20261107063711.3388440-1-hj351016@gmail.com>

> From: Hyunjung Ko <hj351016@gmail.com>
> 
> atcrtc_alarm_isr() schedules atcrtc_dev->rtc_work (atcrtc_alarm_clear),
> whose handler obtains the atcrtc_dev via container_of() and dereferences
> rtc->rtc_dev (guard(rtc_ops)(rtc->rtc_dev)).
> 
> atcrtc_probe() requested the alarm IRQ with devm_request_irq() *before*
> allocating rtc_dev with devm_rtc_allocate_device(), and INIT_WORK()'d
> rtc_work last with no teardown cancel.  Because devres unwinds in reverse
> registration order, on unbind the RTC device is freed before the IRQ, and
> rtc_work is never cancelled at all: an alarm interrupt arriving around
> unbind can run atcrtc_alarm_clear() after rtc->rtc_dev (and the devm
> driver data) have been freed -> use-after-free.
> 
> Allocate the RTC device first, then register rtc_work for device-managed
> cancellation with devm_work_autocancel(), and only then request the IRQ.
> devres now frees the IRQ first (so it can no longer schedule the work),
> then drains the work while rtc_dev is still valid, then frees rtc_dev and
> the driver data.
> 
> Found by code review; not reproduced (requires ATCRTC100 hardware and an
> alarm interrupt racing device unbind).
> 
> Fixes: 7adca706fe16 ("rtc: atcrtc100: Add ATCRTC100 RTC driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunjung Ko <hj351016@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261107063711.3388440-1-hj351016@gmail.com?part=1


      reply	other threads:[~2026-11-07  6:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  6:37 [PATCH] rtc: atcrtc100: drain the alarm work before the RTC device is freed hyunjungg
2026-11-07  6:46 ` 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-202667@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=hj351016@gmail.com \
    --cc=linux-rtc@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.