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

y2038: sparc: Extend sysvipc data structures

sparc, uses a nonstandard variation of the generic sysvipc
data structures, intended to have the padding moved around
so it can deal with big-endian 32-bit user space that has
64-bit time_t.

Unlike most architectures, sparc actually succeeded in
defining this right for big-endian CPUs, but as everyone else
got it wrong, we just use the same hack everywhere.

This takes just take the same approach here that we have for
the asm-generic headers and adds separate 32-bit fields for the
upper halves of the timestamps, to let libc deal with the mess
in user space.

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

+41 -50
+16 -16
arch/sparc/include/asm/compat.h
··· 192 192 193 193 struct compat_semid64_ds { 194 194 struct compat_ipc64_perm sem_perm; 195 - unsigned int __pad1; 196 - compat_time_t sem_otime; 197 - unsigned int __pad2; 198 - compat_time_t sem_ctime; 195 + unsigned int sem_otime_high; 196 + unsigned int sem_otime; 197 + unsigned int sem_ctime_high; 198 + unsigned int sem_ctime; 199 199 u32 sem_nsems; 200 200 u32 __unused1; 201 201 u32 __unused2; ··· 203 203 204 204 struct compat_msqid64_ds { 205 205 struct compat_ipc64_perm msg_perm; 206 - unsigned int __pad1; 207 - compat_time_t msg_stime; 208 - unsigned int __pad2; 209 - compat_time_t msg_rtime; 210 - unsigned int __pad3; 211 - compat_time_t msg_ctime; 206 + unsigned int msg_stime_high; 207 + unsigned int msg_stime; 208 + unsigned int msg_rtime_high; 209 + unsigned int msg_rtime; 210 + unsigned int msg_ctime_high; 211 + unsigned int msg_ctime; 212 212 unsigned int msg_cbytes; 213 213 unsigned int msg_qnum; 214 214 unsigned int msg_qbytes; ··· 220 220 221 221 struct compat_shmid64_ds { 222 222 struct compat_ipc64_perm shm_perm; 223 - unsigned int __pad1; 224 - compat_time_t shm_atime; 225 - unsigned int __pad2; 226 - compat_time_t shm_dtime; 227 - unsigned int __pad3; 228 - compat_time_t shm_ctime; 223 + unsigned int shm_atime_high; 224 + unsigned int shm_atime; 225 + unsigned int shm_dtime_high; 226 + unsigned int shm_dtime; 227 + unsigned int shm_ctime_high; 228 + unsigned int shm_ctime; 229 229 compat_size_t shm_segsz; 230 230 compat_pid_t shm_cpid; 231 231 compat_pid_t shm_lpid;
+9 -13
arch/sparc/include/uapi/asm/msgbuf.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 13 12 */ 14 - 15 - #if defined(__sparc__) && defined(__arch64__) 16 - # define PADDING(x) 17 - #else 18 - # define PADDING(x) unsigned int x; 19 - #endif 20 - 21 - 22 13 struct msqid64_ds { 23 14 struct ipc64_perm msg_perm; 24 - PADDING(__pad1) 15 + #if defined(__sparc__) && defined(__arch64__) 25 16 __kernel_time_t msg_stime; /* last msgsnd time */ 26 - PADDING(__pad2) 27 17 __kernel_time_t msg_rtime; /* last msgrcv time */ 28 - PADDING(__pad3) 29 18 __kernel_time_t msg_ctime; /* last change time */ 19 + #else 20 + unsigned long msg_stime_high; 21 + unsigned long msg_stime; /* last msgsnd time */ 22 + unsigned long msg_rtime_high; 23 + unsigned long msg_rtime; /* last msgrcv time */ 24 + unsigned long msg_ctime_high; 25 + unsigned long msg_ctime; /* last change time */ 26 + #endif 30 27 unsigned long msg_cbytes; /* current number of bytes on queue */ 31 28 unsigned long msg_qnum; /* number of messages in queue */ 32 29 unsigned long msg_qbytes; /* max number of bytes on queue */ ··· 32 35 unsigned long __unused1; 33 36 unsigned long __unused2; 34 37 }; 35 - #undef PADDING 36 38 #endif /* _SPARC_MSGBUF_H */
+7 -9
arch/sparc/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 13 12 */ 14 - #if defined(__sparc__) && defined(__arch64__) 15 - # define PADDING(x) 16 - #else 17 - # define PADDING(x) unsigned int x; 18 - #endif 19 13 20 14 struct semid64_ds { 21 15 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ 22 - PADDING(__pad1) 16 + #if defined(__sparc__) && defined(__arch64__) 23 17 __kernel_time_t sem_otime; /* last semop time */ 24 - PADDING(__pad2) 25 18 __kernel_time_t sem_ctime; /* last change time */ 19 + #else 20 + unsigned long sem_otime_high; 21 + unsigned long sem_otime; /* last semop time */ 22 + unsigned long sem_ctime_high; 23 + unsigned long sem_ctime; /* last change time */ 24 + #endif 26 25 unsigned long sem_nsems; /* no. of semaphores in array */ 27 26 unsigned long __unused1; 28 27 unsigned long __unused2; 29 28 }; 30 - #undef PADDING 31 29 32 30 #endif /* _SPARC64_SEMBUF_H */
+9 -12
arch/sparc/include/uapi/asm/shmbuf.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 13 12 */ 14 13 15 - #if defined(__sparc__) && defined(__arch64__) 16 - # define PADDING(x) 17 - #else 18 - # define PADDING(x) unsigned int x; 19 - #endif 20 - 21 14 struct shmid64_ds { 22 15 struct ipc64_perm shm_perm; /* operation perms */ 23 - PADDING(__pad1) 16 + #if defined(__sparc__) && defined(__arch64__) 24 17 __kernel_time_t shm_atime; /* last attach time */ 25 - PADDING(__pad2) 26 18 __kernel_time_t shm_dtime; /* last detach time */ 27 - PADDING(__pad3) 28 19 __kernel_time_t shm_ctime; /* last change time */ 20 + #else 21 + unsigned long shm_atime_high; 22 + unsigned long shm_atime; /* last attach time */ 23 + unsigned long shm_dtime_high; 24 + unsigned long shm_dtime; /* last detach time */ 25 + unsigned long shm_ctime_high; 26 + unsigned long shm_ctime; /* last change time */ 27 + #endif 29 28 size_t shm_segsz; /* size of segment (bytes) */ 30 29 __kernel_pid_t shm_cpid; /* pid of creator */ 31 30 __kernel_pid_t shm_lpid; /* pid of last operator */ ··· 44 45 unsigned long __unused3; 45 46 unsigned long __unused4; 46 47 }; 47 - 48 - #undef PADDING 49 48 50 49 #endif /* _SPARC_SHMBUF_H */