Linux RTC
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: class: Make the time32 hctosys limit configurable
Date: Sat, 19 Sep 2026 11:16:29 +0200	[thread overview]
Message-ID: <5515c266-f9cd-405f-b7a8-1ec45d9d902a@app.fastmail.com> (raw)
In-Reply-To: <aq3R5QnCpu_fOq8g@gmail.com>

On Sat, Sep 19, 2026, at 02:10, Karl Mehltretter wrote:
> On Wed, Sep 16, 2026 at 08:56:02AM +0100, Arnd Bergmann wrote:
>> > existing safeguard automatically and prevent restoring it without
>> > re-enabling the legacy ABI.
>> 
>> I'm not following your logic here, what is the safeguard?
>
> I meant the existing RTC cutoff. In my glibc test, accepting the
> 2040 RTC date changes time32 clock_gettime() from success to
> EOVERFLOW.

I see. I would just not call that a safeguard, it's more of a
time bomb ;-)

Note that the cutoff was never meant to help systems actually
run beyond 2038, but instead is only needed on very rare systems
with a broken RTC implementation that have a random reset
value if the RTC is enabled in devicetree but the backup battery
is absent or depleted.

>> With a fixed C library, COMPAT_32BIT_TIME=n should act as a safeguard
>> to ensure that no interfaces can be used that limit time to y2038
>> and break unexpectedly in the future. The RTC_HCTOSYS interface
>
> Should we try adding an option to build glibc and other libcs without
> time32 interfaces? Looking at musl's source, its time32 clock_gettime()
> wrapper also calls the time64 implementation and checks whether the
> result fits [1].

I think that would be great, we can certainly try again, at least
with glibc, where at the time the concern was more about the timing
of behavior changes.

There are two separate questions here:

a) Having a libc build only against the time64 interfaces. As far
   as I understand, glibc has used linux-3.2 headers as the
   baseline for kernel compatibility for a long time but one can
   choose a later version. Building with 5.10+ as the minimum
   should already avoid the time32 syscalls, but that could at
   some point be made the minimum header version for 32-bit targets
   or everything.
   musl does not specify a minimum kernel version at all and tries
   to go back as far as possible, so the fallback code is likely
   to stay indefinitely. Rich also does not like the idea of setting
   CONFIG_COMPAT_32BIT_TIME=n (ever), and an unpatched musl
   build will fail in that configuration.
   
b) providing 32-bit interfaces to applications: both libraries
   already provide these as wrappers around the 64-bit internal
   functions, which is part of the problem here but does mean that
   it should be possible to just leave those out. On musl this
   should be very easy (just skip building the compat/time32/
   directory), on glibc I expect this to be much harder as it
   interferes with their idea of having __TIMESIZE=64 vs
   __TIMESIZE=32 as a hardcoded per-architecture setting.

>> actually make it work. Since we have COMPAT_32BIT_TIME as a global
>> option already, it makes a lot of sense to actually use it here
>> as well.
>
> Could we use COMPAT_32BIT_TIME for the default, but still allow the
> limit to be enabled? I could split the update into two patches:
>
> 1. Add RTC_HCTOSYS_TIME32_LIMIT with default y, as posted. This keeps
>    the existing RTC date acceptance by default.
>
> 2. Change the default, keeping the dependency unchanged:
>
>        depends on RTC_HCTOSYS && !64BIT
>        default COMPAT_32BIT_TIME
>
> With RTC_HCTOSYS=y on a 32-bit kernel, the default would allow
> post-2038 RTC dates when COMPAT_32BIT_TIME=n. Integrators could still
> enable the limit without re-enabling legacy syscalls.
>
> I suggest nominating the first patch for stable. Would default
> COMPAT_32BIT_TIME also be suitable for stable?

I think the 'default COMPAT_32BIT_TIME' would absolutely make
sense for stable, since that can only really be set by users that
have a fully 64-bit userspace already and the limit will
cause problems for them.
I would still go one step further and make this

config RTC_HCTOSYS_TIME32_LIMIT
	bool "Reject RTC dates after the 2038 cutoff"
	depends on RTC_HCTOSYS && !64BIT && COMPAT_32BIT_TIME
	default y

to completely disallow it. I think we should wait for Alexandre
to comment here, as it's his subsystem in the end and I'm sure
he has an opinion on the matter.

     Arnd

  reply	other threads:[~2026-09-19  9:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 21:25 [PATCH] rtc: class: Make the time32 hctosys limit configurable Karl Mehltretter
2026-09-14 21:29 ` sashiko-bot
2026-09-15  5:48 ` Arnd Bergmann
2026-09-15 22:37   ` Karl Mehltretter
2026-09-16  6:56     ` Arnd Bergmann
2026-09-19  0:10       ` Karl Mehltretter
2026-09-19  9:16         ` Arnd Bergmann [this message]
2026-09-22 21:37           ` Alexandre Belloni
2026-09-24 15:07             ` Arnd Bergmann
2026-10-05 13:49               ` Alexandre Belloni
2026-10-06 12:33                 ` Arnd Bergmann

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=5515c266-f9cd-405f-b7a8-1ec45d9d902a@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=kmehltretter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@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