* Re: Y2038 related bug in rtc subsystem for 32 bit processors [not found] <BYAPR14MB307829F7F749AAD17473C10BF00D9@BYAPR14MB3078.namprd14.prod.outlook.com> @ 2022-11-22 23:14 ` Alexandre Belloni 0 siblings, 0 replies; only message in thread From: Alexandre Belloni @ 2022-11-22 23:14 UTC (permalink / raw) To: Richard OGrady; +Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org On 22/11/2022 22:27:39+0000, Richard OGrady wrote: > While testing Y2038 compatibility on a 32 bit arm processor I came across this potential bug? in drivers/rtc/class.c (line 76 in v6.0.9) > > > tv64<https://elixir.bootlin.com/linux/latest/C/ident/tv64>.tv_sec<https://elixir.bootlin.com/linux/latest/C/ident/tv_sec> = rtc_tm_to_time64<https://elixir.bootlin.com/linux/latest/C/ident/rtc_tm_to_time64>(&tm<https://elixir.bootlin.com/linux/latest/C/ident/tm>); > > > > #if BITS_PER_LONG<https://elixir.bootlin.com/linux/latest/C/ident/BITS_PER_LONG> == 32 > > if (tv64<https://elixir.bootlin.com/linux/latest/C/ident/tv64>.tv_sec<https://elixir.bootlin.com/linux/latest/C/ident/tv_sec> > INT_MAX<https://elixir.bootlin.com/linux/latest/C/ident/INT_MAX>) { > > err = -ERANGE<https://elixir.bootlin.com/linux/latest/C/ident/ERANGE>; > > goto err_read; > > } > > #endif > > > > err = do_settimeofday64<https://elixir.bootlin.com/linux/latest/C/ident/do_settimeofday64>(&tv64<https://elixir.bootlin.com/linux/latest/C/ident/tv64>); > > > The #if/#endif block above causes the driver to not sync the system clock with the reading from the hwclock once the rtc reading reflects the Y2038 date and later. I certainly could be wrong but it would seem that the block is over-protective and unnecessary. We commented the block out and the system syncs fine with the rtc when the rtc is set to the year 2039. > You are right and this is a workaround for an issue in systemd. Honestly, the solution is to stop relying on rtc_hctosys and set the system time from userspace. -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-22 23:14 UTC | newest] Thread overview: (only message) (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <BYAPR14MB307829F7F749AAD17473C10BF00D9@BYAPR14MB3078.namprd14.prod.outlook.com> 2022-11-22 23:14 ` Y2038 related bug in rtc subsystem for 32 bit processors Alexandre Belloni
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).