Hi Stepan, > 15.04.2019 в 00:08:38 +0200 Lukasz Majewski написал: > > +# if defined __NR_clock_settime64 > > + /* Make sure that passed __timespec64 struct pad is 0. */ > > + struct __timespec64 ts = *tp; > > + ts.tv_pad = 0; > > + return INLINE_SYSCALL_CALL (clock_settime64, clock_id, &ts); > > Isn't kernel supposed to zero out padding on its own? > At least comment in kernel's get_timespec64 says so: > > /* Zero out the padding for 32 bit systems or in compat mode > */ if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall()) > kts.tv_nsec &= 0xFFFFFFFFUL; >
For ARM (and x86) 32 bit machines I do use following syscalls (like clock_settime64): https://elixir.bootlin.com/linux/v5.1-rc4/source/arch/arm/tools/syscall.tbl#L420 which are providing 64 bit time support on 32 bit systems. Yes. In those systems the upper part (32 bits) of tv_nsec is cleared up with mask in the kernel. However, I would prefer not to pass random data to the kernel, and hence I do clear it up explicitly in glibc. > The code looks buggy though. It fails to zero out the padding in > 32-bit kernels. For the 32 bit systems without Y2038 support enabled in glibc - the clock_settime would be used, which corresponds to sys_clock_settime32() in the kernel. > That part is probably broken since > 98f76206b3350 ("compat: Cleanup in_compat_syscall() callers"). > > And, hmm, is CONFIG_64BIT_TIME enabled anywhere? When I do use clock_settime64 on the glibc side (with _TIME_BITS=64), I do not need to enable such config in the kernel. If the kernel supports this call (5.1+), then use it, otherwise fallback to clock_settime(). For 64 bit systems, I do not change the execution path. If you are interested, please look on the following repo (which has some more commits than those posted to the mailing list): https://github.com/lmajewski/y2038_glibc/commits/Y2038-2.29-glibc-__clock-internal-struct-timespec-v1 And meta layer for testing. https://github.com/lmajewski/meta-y2038 Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lu...@denx.de
pgpTWLzGj6GDd.pgp
Description: OpenPGP digital signature