ipc: mqueue: Replace timespec with timespec64

struct timespec is not y2038 safe. Replace
all uses of timespec by y2038 safe struct timespec64.

Even though timespec is used here to represent timeouts,
replace these with timespec64 so that it facilitates
in verification by creating a y2038 safe kernel image
that is free of timespec.

The syscall interfaces themselves are not changed as part
of the patch. They will be part of a different series.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Richard Guy Briggs <rgb@redhat.com>
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Deepa Dinamani and committed by
Al Viro
b9047726 3ef56dc2

+24 -24
+3 -3
include/linux/audit.h
··· 351 351 extern int __audit_sockaddr(int len, void *addr); 352 352 extern void __audit_fd_pair(int fd1, int fd2); 353 353 extern void __audit_mq_open(int oflag, umode_t mode, struct mq_attr *attr); 354 - extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout); 354 + extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout); 355 355 extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification); 356 356 extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); 357 357 extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, ··· 412 412 if (unlikely(!audit_dummy_context())) 413 413 __audit_mq_open(oflag, mode, attr); 414 414 } 415 - static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) 415 + static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec64 *abs_timeout) 416 416 { 417 417 if (unlikely(!audit_dummy_context())) 418 418 __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout); ··· 549 549 { } 550 550 static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, 551 551 unsigned int msg_prio, 552 - const struct timespec *abs_timeout) 552 + const struct timespec64 *abs_timeout) 553 553 { } 554 554 static inline void audit_mq_notify(mqd_t mqdes, 555 555 const struct sigevent *notification)
+14 -14
ipc/mqueue.c
··· 668 668 } 669 669 670 670 static int prepare_timeout(const struct timespec __user *u_abs_timeout, 671 - struct timespec *ts) 671 + struct timespec64 *ts) 672 672 { 673 - if (copy_from_user(ts, u_abs_timeout, sizeof(struct timespec))) 673 + if (get_timespec64(ts, u_abs_timeout)) 674 674 return -EFAULT; 675 - if (!timespec_valid(ts)) 675 + if (!timespec64_valid(ts)) 676 676 return -EINVAL; 677 677 return 0; 678 678 } ··· 962 962 963 963 static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, 964 964 size_t msg_len, unsigned int msg_prio, 965 - struct timespec *ts) 965 + struct timespec64 *ts) 966 966 { 967 967 struct fd f; 968 968 struct inode *inode; ··· 979 979 return -EINVAL; 980 980 981 981 if (ts) { 982 - expires = timespec_to_ktime(*ts); 982 + expires = timespec64_to_ktime(*ts); 983 983 timeout = &expires; 984 984 } 985 985 ··· 1080 1080 1081 1081 static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr, 1082 1082 size_t msg_len, unsigned int __user *u_msg_prio, 1083 - struct timespec *ts) 1083 + struct timespec64 *ts) 1084 1084 { 1085 1085 ssize_t ret; 1086 1086 struct msg_msg *msg_ptr; ··· 1092 1092 struct posix_msg_tree_node *new_leaf = NULL; 1093 1093 1094 1094 if (ts) { 1095 - expires = timespec_to_ktime(*ts); 1095 + expires = timespec64_to_ktime(*ts); 1096 1096 timeout = &expires; 1097 1097 } 1098 1098 ··· 1184 1184 size_t, msg_len, unsigned int, msg_prio, 1185 1185 const struct timespec __user *, u_abs_timeout) 1186 1186 { 1187 - struct timespec ts, *p = NULL; 1187 + struct timespec64 ts, *p = NULL; 1188 1188 if (u_abs_timeout) { 1189 1189 int res = prepare_timeout(u_abs_timeout, &ts); 1190 1190 if (res) ··· 1198 1198 size_t, msg_len, unsigned int __user *, u_msg_prio, 1199 1199 const struct timespec __user *, u_abs_timeout) 1200 1200 { 1201 - struct timespec ts, *p = NULL; 1201 + struct timespec64 ts, *p = NULL; 1202 1202 if (u_abs_timeout) { 1203 1203 int res = prepare_timeout(u_abs_timeout, &ts); 1204 1204 if (res) ··· 1475 1475 } 1476 1476 1477 1477 static int compat_prepare_timeout(const struct compat_timespec __user *p, 1478 - struct timespec *ts) 1478 + struct timespec64 *ts) 1479 1479 { 1480 - if (compat_get_timespec(ts, p)) 1480 + if (compat_get_timespec64(ts, p)) 1481 1481 return -EFAULT; 1482 - if (!timespec_valid(ts)) 1482 + if (!timespec64_valid(ts)) 1483 1483 return -EINVAL; 1484 1484 return 0; 1485 1485 } ··· 1489 1489 compat_size_t, msg_len, unsigned int, msg_prio, 1490 1490 const struct compat_timespec __user *, u_abs_timeout) 1491 1491 { 1492 - struct timespec ts, *p = NULL; 1492 + struct timespec64 ts, *p = NULL; 1493 1493 if (u_abs_timeout) { 1494 1494 int res = compat_prepare_timeout(u_abs_timeout, &ts); 1495 1495 if (res) ··· 1504 1504 compat_size_t, msg_len, unsigned int __user *, u_msg_prio, 1505 1505 const struct compat_timespec __user *, u_abs_timeout) 1506 1506 { 1507 - struct timespec ts, *p = NULL; 1507 + struct timespec64 ts, *p = NULL; 1508 1508 if (u_abs_timeout) { 1509 1509 int res = compat_prepare_timeout(u_abs_timeout, &ts); 1510 1510 if (res)
+1 -1
kernel/audit.h
··· 182 182 mqd_t mqdes; 183 183 size_t msg_len; 184 184 unsigned int msg_prio; 185 - struct timespec abs_timeout; 185 + struct timespec64 abs_timeout; 186 186 } mq_sendrecv; 187 187 struct { 188 188 int oflag;
+6 -6
kernel/auditsc.c
··· 1235 1235 case AUDIT_MQ_SENDRECV: 1236 1236 audit_log_format(ab, 1237 1237 "mqdes=%d msg_len=%zd msg_prio=%u " 1238 - "abs_timeout_sec=%ld abs_timeout_nsec=%ld", 1238 + "abs_timeout_sec=%lld abs_timeout_nsec=%ld", 1239 1239 context->mq_sendrecv.mqdes, 1240 1240 context->mq_sendrecv.msg_len, 1241 1241 context->mq_sendrecv.msg_prio, 1242 - context->mq_sendrecv.abs_timeout.tv_sec, 1242 + (long long) context->mq_sendrecv.abs_timeout.tv_sec, 1243 1243 context->mq_sendrecv.abs_timeout.tv_nsec); 1244 1244 break; 1245 1245 case AUDIT_MQ_NOTIFY: ··· 2083 2083 * 2084 2084 */ 2085 2085 void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, 2086 - const struct timespec *abs_timeout) 2086 + const struct timespec64 *abs_timeout) 2087 2087 { 2088 2088 struct audit_context *context = current->audit_context; 2089 - struct timespec *p = &context->mq_sendrecv.abs_timeout; 2089 + struct timespec64 *p = &context->mq_sendrecv.abs_timeout; 2090 2090 2091 2091 if (abs_timeout) 2092 - memcpy(p, abs_timeout, sizeof(struct timespec)); 2092 + memcpy(p, abs_timeout, sizeof(*p)); 2093 2093 else 2094 - memset(p, 0, sizeof(struct timespec)); 2094 + memset(p, 0, sizeof(*p)); 2095 2095 2096 2096 context->mq_sendrecv.mqdes = mqdes; 2097 2097 context->mq_sendrecv.msg_len = msg_len;