Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

y2038: x86: Extend sysvipc data structures

This extends the x86 copy of the sysvipc data structures to deal with
32-bit user space that has 64-bit time_t and wants to see timestamps
beyond 2038.

Fortunately, x86 has padding for this purpose in all the data structures,
so we can just add extra fields. With msgid64_ds and shmid64_ds, the
data structure is identical to the asm-generic version, which we have
already extended.

For some reason however, the 64-bit version of semid64_ds ended up with
extra padding, so I'm implementing the same approach as the asm-generic
version here, by using separate fields for the upper and lower halves
of the two timestamps.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+26 -17
+16 -16
arch/x86/include/asm/compat.h
··· 134 134 135 135 struct compat_semid64_ds { 136 136 struct compat_ipc64_perm sem_perm; 137 - compat_time_t sem_otime; 138 - compat_ulong_t __unused1; 139 - compat_time_t sem_ctime; 140 - compat_ulong_t __unused2; 137 + compat_ulong_t sem_otime; 138 + compat_ulong_t sem_otime_high; 139 + compat_ulong_t sem_ctime; 140 + compat_ulong_t sem_ctime_high; 141 141 compat_ulong_t sem_nsems; 142 142 compat_ulong_t __unused3; 143 143 compat_ulong_t __unused4; ··· 145 145 146 146 struct compat_msqid64_ds { 147 147 struct compat_ipc64_perm msg_perm; 148 - compat_time_t msg_stime; 149 - compat_ulong_t __unused1; 150 - compat_time_t msg_rtime; 151 - compat_ulong_t __unused2; 152 - compat_time_t msg_ctime; 153 - compat_ulong_t __unused3; 148 + compat_ulong_t msg_stime; 149 + compat_ulong_t msg_stime_high; 150 + compat_ulong_t msg_rtime; 151 + compat_ulong_t msg_rtime_high; 152 + compat_ulong_t msg_ctime; 153 + compat_ulong_t msg_ctime_high; 154 154 compat_ulong_t msg_cbytes; 155 155 compat_ulong_t msg_qnum; 156 156 compat_ulong_t msg_qbytes; ··· 163 163 struct compat_shmid64_ds { 164 164 struct compat_ipc64_perm shm_perm; 165 165 compat_size_t shm_segsz; 166 - compat_time_t shm_atime; 167 - compat_ulong_t __unused1; 168 - compat_time_t shm_dtime; 169 - compat_ulong_t __unused2; 170 - compat_time_t shm_ctime; 171 - compat_ulong_t __unused3; 166 + compat_ulong_t shm_atime; 167 + compat_ulong_t shm_atime_high; 168 + compat_ulong_t shm_dtime; 169 + compat_ulong_t shm_dtime_high; 170 + compat_ulong_t shm_ctime; 171 + compat_ulong_t shm_ctime_high; 172 172 compat_pid_t shm_cpid; 173 173 compat_pid_t shm_lpid; 174 174 compat_ulong_t shm_nattch;
+10 -1
arch/x86/include/uapi/asm/sembuf.h
··· 8 8 * between kernel and user space. 9 9 * 10 10 * Pad space is left for: 11 - * - 64-bit time_t to solve y2038 problem 12 11 * - 2 miscellaneous 32-bit values 12 + * 13 + * x86_64 and x32 incorrectly added padding here, so the structures 14 + * are still incompatible with the padding on x86. 13 15 */ 14 16 struct semid64_ds { 15 17 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ 18 + #ifdef __i386__ 19 + unsigned long sem_otime; /* last semop time */ 20 + unsigned long sem_otime_high; 21 + unsigned long sem_ctime; /* last change time */ 22 + unsigned long sem_ctime_high; 23 + #else 16 24 __kernel_time_t sem_otime; /* last semop time */ 17 25 __kernel_ulong_t __unused1; 18 26 __kernel_time_t sem_ctime; /* last change time */ 19 27 __kernel_ulong_t __unused2; 28 + #endif 20 29 __kernel_ulong_t sem_nsems; /* no. of semaphores in array */ 21 30 __kernel_ulong_t __unused3; 22 31 __kernel_ulong_t __unused4;