7729eb
commit cb9b8b5d7670df1a13544857640efd86a299d0e4
7729eb
Author: Stafford Horne <shorne@gmail.com>
7729eb
Date:   Fri Oct 15 06:17:41 2021 +0900
7729eb
7729eb
    timex: Use 64-bit fields on 32-bit TIMESIZE=64 systems (BZ #28469)
7729eb
    
7729eb
    This was found when testing the OpenRISC port I am working on.  These
7729eb
    two tests fail with SIGSEGV:
7729eb
    
7729eb
      FAIL: misc/tst-ntp_gettime
7729eb
      FAIL: misc/tst-ntp_gettimex
7729eb
    
7729eb
    This was found to be due to the kernel overwriting the stack space
7729eb
    allocated by the timex structure.  The reason for the overwrite being
7729eb
    that the kernel timex has 64-bit fields and user space code only
7729eb
    allocates enough stack space for timex with 32-bit fields.
7729eb
    
7729eb
    On 32-bit systems with TIMESIZE=64 __USE_TIME_BITS64 is not defined.
7729eb
    This causes the timex structure to use 32-bit fields with type
7729eb
    __syscall_slong_t.
7729eb
    
7729eb
    This patch adjusts the ifdef condition to allow 32-bit systems with
7729eb
    TIMESIZE=64 to use the 64-bit long long timex definition.
7729eb
    
7729eb
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
7729eb
    
7729eb
    (Cherry picked from commit 1d550265a75b412cea4889a50b101395f6a8e025)
7729eb
7729eb
diff --git a/sysdeps/unix/sysv/linux/bits/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h
7729eb
index ee37694e8f09a8e4..4a5db6deca10de58 100644
7729eb
--- a/sysdeps/unix/sysv/linux/bits/timex.h
7729eb
+++ b/sysdeps/unix/sysv/linux/bits/timex.h
7729eb
@@ -25,7 +25,7 @@
7729eb
 
7729eb
 struct timex
7729eb
 {
7729eb
-# ifdef __USE_TIME_BITS64
7729eb
+# if defined __USE_TIME_BITS64 || (__TIMESIZE == 64 && __WORDSIZE == 32)
7729eb
   unsigned int modes;          /* mode selector */
7729eb
   int :32;                     /* pad */
7729eb
   long long offset;            /* time offset (usec) */