devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: devicetree@vger.kernel.org, wsa+renesas@sang-engineering.com,
	linux-rtc@vger.kernel.org, robh@kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	conor+dt@kernel.org
Subject: Re: [PATCH v4 06/15] rtc: rzn1: Fix alarm range check truncation on 32-bit systems
Date: Wed, 19 Aug 2026 10:50:28 +0000	[thread overview]
Message-ID: <20260819105028.70F3A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260819103926.2136712-7-prabhakar.mahadev-lad.rj@bp.renesas.com>

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

Pre-existing issues:
- [High] Race condition in rzn1_rtc_set_alarm between hardware programming and the alarm interrupt handler.
--

--- Patch [6]: [PATCH v4 06/15] rtc: rzn1: Fix alarm range check truncation on 32-bit systems ---
commit 87931837ad8bba978fe3d99a5140167b545c3e4d
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

rtc: rzn1: Fix alarm range check truncation on 32-bit systems

This commit changes the types of alarm and farest to time64_t to prevent
truncation on 32-bit systems. It also replaces time_after() with a direct
signed comparison.

> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index d03d252fdfe1f..94d592e88a044 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c

[ ... ]

> @@ -269,7 +269,7 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
>  	/* We cannot set alarms more than one week ahead */
>  	farest = rtc_tm_to_time64(&tm_now) + rtc->rtcdev->alarm_offset_max;
>  	alarm = rtc_tm_to_time64(tm);
> -	if (time_after(alarm, farest))
> +	if (alarm > farest)
>  		return -ERANGE;
>  
>  	writel(bin2bcd(tm->tm_min), rtc->base + RZN1_RTC_ALM);

[Severity: High]
This is a pre-existing issue, but can this sequence of register writes
trigger a spurious interrupt?

In drivers/rtc/rtc-rzn1.c:rzn1_rtc_set_alarm(), the driver writes to the
hardware alarm registers without first explicitly disabling the alarm
interrupt.

If the RTC core enqueues a new alarm while a previous alarm is active,
could the hardware registers temporarily match the current time during
these sequential writes and trigger an interrupt?

If an interrupt fires here, it looks like rzn1_rtc_alarm_irq() would
execute using the old, stale rtc->tm_alarm state, since it hasn't been
updated yet. Could this cause it to incorrectly switch to 1-second
interrupts or fire a spurious event?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260819103926.2136712-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=6

  reply	other threads:[~2026-08-19 10:50 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 10:39 [PATCH v4 00/15] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-08-19 10:39 ` [PATCH v4 01/15] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-08-19 10:48   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 02/15] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-08-19 10:46   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 03/15] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary Prabhakar
2026-08-19 10:53   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 04/15] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-08-19 10:43   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 05/15] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-08-19 10:44   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 06/15] rtc: rzn1: Fix alarm range check truncation on 32-bit systems Prabhakar
2026-08-19 10:50   ` sashiko-bot [this message]
2026-08-19 10:39 ` [PATCH v4 07/15] rtc: rzn1: Replace remove callback with devm_add_action_or_reset() Prabhakar
2026-08-19 10:50   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 08/15] rtc: rzn1: Use pm_runtime_put_sync() in rzn1_rtc_disable_hardware() Prabhakar
2026-08-19 10:51   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 09/15] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-08-19 10:47   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 10/15] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-08-19 10:46   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 11/15] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-08-19 10:46   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 12/15] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-08-19 10:49   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 13/15] rtc: rzn1: Add OF match data to gate SUBU " Prabhakar
2026-08-19 10:47   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 14/15] rtc: rzn1: Drop trailing comma from OF match table sentinel Prabhakar
2026-08-19 10:47   ` sashiko-bot
2026-08-19 10:39 ` [PATCH v4 15/15] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-08-19 10:52   ` 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=20260819105028.70F3A1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /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;
as well as URLs for NNTP newsgroup(s).