On Tue, 2015-15-12 at 07:09:14 UTC, Daniel Axtens wrote: > GregorianDay() is supposed to calculate the day of the week > (tm->tm_wday) for a given day/month/year. In that calcuation it > indexed into an array called MonthOffset using tm->tm_mon-1. However > tm_mon is zero-based, not one-based, so this is off-by-one. It also > means that every January, GregoiranDay() will access element -1 of > the MonthOffset array. > > It also doesn't appear to be a correct algorithm either: see in > contrast kernel/time/timeconv.c's time_to_tm function. > > It's been broken forever, which suggests no-one in userland uses > this. It looks like no-one in the kernel uses tm->tm_wday either > (see e.g. drivers/rtc/rtc-ds1305.c:319). > > tm->tm_wday is conventionally set to -1 when not available in > hardware so we can simply set it to -1 and drop the function. > (There are over a dozen other drivers in drivers/rtc that do > this.) > > Found using UBSAN. > > Cc: Andrey Ryabinin <aryabi...@virtuozzo.com> > Cc: Andrew Morton <a...@linux-foundation.org> # as an example of what UBSan > finds. > Cc: Alessandro Zummo <a.zu...@towertech.it> > Cc: Alexandre Belloni <alexandre.bell...@free-electrons.com> > Cc: rtc-li...@googlegroups.com > Signed-off-by: Daniel Axtens <d...@axtens.net> > Acked-by: Alexandre Belloni <alexandre.bell...@free-electrons.com>
Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/00b912b0c88e690b1662067497 cheers _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev