summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2017-08-02 22:51:12 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-09-03 20:21:24 -0400
commit50578ea97a2a352c109bd1657e667b212faf2cbb (patch)
tree7a242252edae5c64837daa28d9d008b18c2b445c
parentb9047726386bb538cf5e4f52a9f04eb556eebc67 (diff)
ipc: msg: Make msg_queue timestamps y2038 safe
time_t is not y2038 safe. Replace all uses of time_t by y2038 safe time64_t. Similarly, replace the calls to get_seconds() with y2038 safe ktime_get_real_seconds(). Note that this preserves fast access on 64 bit systems, but 32 bit systems need sequence counters. 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> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--include/linux/msg.h7
-rw-r--r--ipc/msg.c6
2 files changed, 7 insertions, 6 deletions
diff --git a/include/linux/msg.h b/include/linux/msg.h
index 4e5ec3cbf464..05115342daa3 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -2,6 +2,7 @@
2#define _LINUX_MSG_H 2#define _LINUX_MSG_H
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/time64.h>
5#include <uapi/linux/msg.h> 6#include <uapi/linux/msg.h>
6 7
7/* one msg_msg structure for each message */ 8/* one msg_msg structure for each message */
@@ -17,9 +18,9 @@ struct msg_msg {
17/* one msq_queue structure for each present queue on the system */ 18/* one msq_queue structure for each present queue on the system */
18struct msg_queue { 19struct msg_queue {
19 struct kern_ipc_perm q_perm; 20 struct kern_ipc_perm q_perm;
20 time_t q_stime; /* last msgsnd time */ 21 time64_t q_stime; /* last msgsnd time */
21 time_t q_rtime; /* last msgrcv time */ 22 time64_t q_rtime; /* last msgrcv time */
22 time_t q_ctime; /* last change time */ 23 time64_t q_ctime; /* last change time */
23 unsigned long q_cbytes; /* current number of bytes on queue */ 24 unsigned long q_cbytes; /* current number of bytes on queue */
24 unsigned long q_qnum; /* number of messages in queue */ 25 unsigned long q_qnum; /* number of messages in queue */
25 unsigned long q_qbytes; /* max number of bytes on queue */ 26 unsigned long q_qbytes; /* max number of bytes on queue */
diff --git a/ipc/msg.c b/ipc/msg.c
index 855da19c765a..0e7ccfc0700b 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -133,7 +133,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
133 } 133 }
134 134
135 msq->q_stime = msq->q_rtime = 0; 135 msq->q_stime = msq->q_rtime = 0;
136 msq->q_ctime = get_seconds(); 136 msq->q_ctime = ktime_get_real_seconds();
137 msq->q_cbytes = msq->q_qnum = 0; 137 msq->q_cbytes = msq->q_qnum = 0;
138 msq->q_qbytes = ns->msg_ctlmnb; 138 msq->q_qbytes = ns->msg_ctlmnb;
139 msq->q_lspid = msq->q_lrpid = 0; 139 msq->q_lspid = msq->q_lrpid = 0;
@@ -406,7 +406,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
406 406
407 msq->q_qbytes = msqid64->msg_qbytes; 407 msq->q_qbytes = msqid64->msg_qbytes;
408 408
409 msq->q_ctime = get_seconds(); 409 msq->q_ctime = ktime_get_real_seconds();
410 /* 410 /*
411 * Sleeping receivers might be excluded by 411 * Sleeping receivers might be excluded by
412 * stricter permissions. 412 * stricter permissions.
@@ -1181,7 +1181,7 @@ static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
1181 struct msg_queue *msq = it; 1181 struct msg_queue *msq = it;
1182 1182
1183 seq_printf(s, 1183 seq_printf(s,
1184 "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n", 1184 "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10llu %10llu %10llu\n",
1185 msq->q_perm.key, 1185 msq->q_perm.key,
1186 msq->q_perm.id, 1186 msq->q_perm.id,
1187 msq->q_perm.mode, 1187 msq->q_perm.mode,