Linux RTC
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: "Einar Jón" <tolvupostur@gmail.com>
Cc: linux-rtc@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] rtc: class: Fix max epoch in rtc_hctosys on 32-bit systems
Date: Tue, 18 Feb 2025 14:30:39 +0100	[thread overview]
Message-ID: <20250218133039de7b063d@mail.local> (raw)
In-Reply-To: <CABhNV21ZptxH9d4NyPo1xivS0GAXNsoLMLpPSRAsT8h5CX9hDw@mail.gmail.com>

On 18/02/2025 13:45:56+0100, Einar Jón wrote:
> Hello again
> 
> On second thought, removing is too general.
> But it's still very much broken. Is there any reason why this was not
> merged?
> https://lore.kernel.org/all/c5e8ab50-aacb-4651-8893-a6dd9edcd155@app.fastmail.com/T/
> 
> Any thoughts on how this should be handled?

The first step is to convince Lennart that mandating RTC_HCTOSYS xwas a
bad idea, the second step is to let userspace set the time instead. The
kernel can't take the proper decision because it simply doesn't know
whether userspace is TIME64 ready or not.

> 
> Best regards
> Einar Jón
> 
> On Tue, 18 Feb 2025 at 12:12, Einar Jon Gunnarsson <tolvupostur@gmail.com>
> wrote:
> 
> > The check for BITS_PER_LONG == 32 makes no sense after calling
> > tv64.tv_sec = rtc_tm_to_time64(&tm);
> >
> > With this check, any 32-bit system will silently return an -ERANGE error
> > instead of setting the correct time if the hardware clock is storing a
> > date after Y2K38 (2038-01-19).
> > Without this check they should all work as intended, since the rest of
> > the function is perfectly 64-bit safe.
> >
> > Fixes: f9b2a4d6a5f1 ("rtc: class: support hctosys from modular RTC
> > drivers")
> >
> > Signed-off-by: Einar Jon Gunnarsson <tolvupostur@gmail.com>
> > ---
> >  drivers/rtc/class.c | 7 -------
> >  1 file changed, 7 deletions(-)
> >
> > diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
> > index e31fa0ad127e..df58edf99ed3 100644
> > --- a/drivers/rtc/class.c
> > +++ b/drivers/rtc/class.c
> > @@ -72,13 +72,6 @@ static void rtc_hctosys(struct rtc_device *rtc)
> >
> >         tv64.tv_sec = rtc_tm_to_time64(&tm);
> >
> > -#if BITS_PER_LONG == 32
> > -       if (tv64.tv_sec > INT_MAX) {
> > -               err = -ERANGE;
> > -               goto err_read;
> > -       }
> > -#endif
> > -
> >         err = do_settimeofday64(&tv64);
> >
> >         dev_info(rtc->dev.parent, "setting system clock to %ptR UTC
> > (%lld)\n",
> > --
> > 2.34.1
> >
> >
> 
> -- 
> Regards
> Einar Jón

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2025-02-18 13:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 11:11 [PATCH] rtc: class: Fix max epoch in rtc_hctosys on 32-bit systems Einar Jon Gunnarsson
     [not found] ` <CABhNV21ZptxH9d4NyPo1xivS0GAXNsoLMLpPSRAsT8h5CX9hDw@mail.gmail.com>
2025-02-18 13:28   ` Einar Jón
2025-02-18 13:30   ` Alexandre Belloni [this message]
2025-02-18 14:51     ` Arnd Bergmann
2025-02-18 15:40       ` Alexandre Belloni
2025-02-18 16:00         ` Einar Jón
2025-02-18 16:05         ` Arnd Bergmann
2025-02-18 16:39           ` Alexandre Belloni
2025-02-19  7:36             ` Einar Jón

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=20250218133039de7b063d@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=arnd@arndb.de \
    --cc=linux-rtc@vger.kernel.org \
    --cc=tolvupostur@gmail.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