Skip to content

Commit 91b9b0d

Browse files
committed
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>
1 parent f69c97f commit 91b9b0d

4 files changed

Lines changed: 41 additions & 50 deletions

File tree

‎arch/sparc/include/asm/compat.h‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,23 @@ struct compat_ipc64_perm {
192192

193193
struct compat_semid64_ds {
194194
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;
199199
u32 sem_nsems;
200200
u32 __unused1;
201201
u32 __unused2;
202202
};
203203

204204
struct compat_msqid64_ds {
205205
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;
212212
unsigned int msg_cbytes;
213213
unsigned int msg_qnum;
214214
unsigned int msg_qbytes;
@@ -220,12 +220,12 @@ struct compat_msqid64_ds {
220220

221221
struct compat_shmid64_ds {
222222
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;
229229
compat_size_t shm_segsz;
230230
compat_pid_t shm_cpid;
231231
compat_pid_t shm_lpid;

‎arch/sparc/include/uapi/asm/msgbuf.h‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,22 @@
88
* between kernel and user space.
99
*
1010
* Pad space is left for:
11-
* - 64-bit time_t to solve y2038 problem
1211
* - 2 miscellaneous 32-bit values
1312
*/
14-
15-
#if defined(__sparc__) && defined(__arch64__)
16-
# define PADDING(x)
17-
#else
18-
# define PADDING(x) unsigned int x;
19-
#endif
20-
21-
2213
struct msqid64_ds {
2314
struct ipc64_perm msg_perm;
24-
PADDING(__pad1)
15+
#if defined(__sparc__) && defined(__arch64__)
2516
__kernel_time_t msg_stime; /* last msgsnd time */
26-
PADDING(__pad2)
2717
__kernel_time_t msg_rtime; /* last msgrcv time */
28-
PADDING(__pad3)
2918
__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
3027
unsigned long msg_cbytes; /* current number of bytes on queue */
3128
unsigned long msg_qnum; /* number of messages in queue */
3229
unsigned long msg_qbytes; /* max number of bytes on queue */
@@ -35,5 +32,4 @@ struct msqid64_ds {
3532
unsigned long __unused1;
3633
unsigned long __unused2;
3734
};
38-
#undef PADDING
3935
#endif /* _SPARC_MSGBUF_H */

‎arch/sparc/include/uapi/asm/sembuf.h‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@
88
* between kernel and user space.
99
*
1010
* Pad space is left for:
11-
* - 64-bit time_t to solve y2038 problem
1211
* - 2 miscellaneous 32-bit values
1312
*/
14-
#if defined(__sparc__) && defined(__arch64__)
15-
# define PADDING(x)
16-
#else
17-
# define PADDING(x) unsigned int x;
18-
#endif
1913

2014
struct semid64_ds {
2115
struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
22-
PADDING(__pad1)
16+
#if defined(__sparc__) && defined(__arch64__)
2317
__kernel_time_t sem_otime; /* last semop time */
24-
PADDING(__pad2)
2518
__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
2625
unsigned long sem_nsems; /* no. of semaphores in array */
2726
unsigned long __unused1;
2827
unsigned long __unused2;
2928
};
30-
#undef PADDING
3129

3230
#endif /* _SPARC64_SEMBUF_H */

‎arch/sparc/include/uapi/asm/shmbuf.h‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,23 @@
88
* between kernel and user space.
99
*
1010
* Pad space is left for:
11-
* - 64-bit time_t to solve y2038 problem
1211
* - 2 miscellaneous 32-bit values
1312
*/
1413

15-
#if defined(__sparc__) && defined(__arch64__)
16-
# define PADDING(x)
17-
#else
18-
# define PADDING(x) unsigned int x;
19-
#endif
20-
2114
struct shmid64_ds {
2215
struct ipc64_perm shm_perm; /* operation perms */
23-
PADDING(__pad1)
16+
#if defined(__sparc__) && defined(__arch64__)
2417
__kernel_time_t shm_atime; /* last attach time */
25-
PADDING(__pad2)
2618
__kernel_time_t shm_dtime; /* last detach time */
27-
PADDING(__pad3)
2819
__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
2928
size_t shm_segsz; /* size of segment (bytes) */
3029
__kernel_pid_t shm_cpid; /* pid of creator */
3130
__kernel_pid_t shm_lpid; /* pid of last operator */
@@ -46,6 +45,4 @@ struct shminfo64 {
4645
unsigned long __unused4;
4746
};
4847

49-
#undef PADDING
50-
5148
#endif /* _SPARC_SHMBUF_H */

0 commit comments

Comments
 (0)