Skip to content

Commit 50578ea

Browse files
deepa-hubAl Viro
authored andcommitted
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>
1 parent b904772 commit 50578ea

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎include/linux/msg.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _LINUX_MSG_H
33

44
#include <linux/list.h>
5+
#include <linux/time64.h>
56
#include <uapi/linux/msg.h>
67

78
/* one msg_msg structure for each message */
@@ -17,9 +18,9 @@ struct msg_msg {
1718
/* one msq_queue structure for each present queue on the system */
1819
struct msg_queue {
1920
struct kern_ipc_perm q_perm;
20-
time_t q_stime; /* last msgsnd time */
21-
time_t q_rtime; /* last msgrcv time */
22-
time_t q_ctime; /* last change time */
21+
time64_t q_stime; /* last msgsnd time */
22+
time64_t q_rtime; /* last msgrcv time */
23+
time64_t q_ctime; /* last change time */
2324
unsigned long q_cbytes; /* current number of bytes on queue */
2425
unsigned long q_qnum; /* number of messages in queue */
2526
unsigned long q_qbytes; /* max number of bytes on queue */

‎ipc/msg.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
133133
}
134134

135135
msq->q_stime = msq->q_rtime = 0;
136-
msq->q_ctime = get_seconds();
136+
msq->q_ctime = ktime_get_real_seconds();
137137
msq->q_cbytes = msq->q_qnum = 0;
138138
msq->q_qbytes = ns->msg_ctlmnb;
139139
msq->q_lspid = msq->q_lrpid = 0;
@@ -406,7 +406,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd,
406406

407407
msq->q_qbytes = msqid64->msg_qbytes;
408408

409-
msq->q_ctime = get_seconds();
409+
msq->q_ctime = ktime_get_real_seconds();
410410
/*
411411
* Sleeping receivers might be excluded by
412412
* stricter permissions.
@@ -1181,7 +1181,7 @@ static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
11811181
struct msg_queue *msq = it;
11821182

11831183
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",
11851185
msq->q_perm.key,
11861186
msq->q_perm.id,
11871187
msq->q_perm.mode,

0 commit comments

Comments
 (0)