Skip to content

Commit 7ff2819

Browse files
deepa-hubAl Viro
authored andcommitted
ipc: shm: Make shmid_kernel 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 e54d02b commit 7ff2819

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎include/linux/shm.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ struct shmid_kernel /* private to the kernel */
1212
struct file *shm_file;
1313
unsigned long shm_nattch;
1414
unsigned long shm_segsz;
15-
time_t shm_atim;
16-
time_t shm_dtim;
17-
time_t shm_ctim;
15+
time64_t shm_atim;
16+
time64_t shm_dtim;
17+
time64_t shm_ctim;
1818
pid_t shm_cprid;
1919
pid_t shm_lprid;
2020
struct user_struct *mlock_user;

‎ipc/shm.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static int __shm_open(struct vm_area_struct *vma)
200200
if (IS_ERR(shp))
201201
return PTR_ERR(shp);
202202

203-
shp->shm_atim = get_seconds();
203+
shp->shm_atim = ktime_get_real_seconds();
204204
shp->shm_lprid = task_tgid_vnr(current);
205205
shp->shm_nattch++;
206206
shm_unlock(shp);
@@ -287,7 +287,7 @@ static void shm_close(struct vm_area_struct *vma)
287287
goto done; /* no-op */
288288

289289
shp->shm_lprid = task_tgid_vnr(current);
290-
shp->shm_dtim = get_seconds();
290+
shp->shm_dtim = ktime_get_real_seconds();
291291
shp->shm_nattch--;
292292
if (shm_may_destroy(ns, shp))
293293
shm_destroy(ns, shp);
@@ -592,7 +592,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
592592
shp->shm_cprid = task_tgid_vnr(current);
593593
shp->shm_lprid = 0;
594594
shp->shm_atim = shp->shm_dtim = 0;
595-
shp->shm_ctim = get_seconds();
595+
shp->shm_ctim = ktime_get_real_seconds();
596596
shp->shm_segsz = size;
597597
shp->shm_nattch = 0;
598598
shp->shm_file = file;
@@ -846,7 +846,7 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd,
846846
err = ipc_update_perm(&shmid64->shm_perm, ipcp);
847847
if (err)
848848
goto out_unlock0;
849-
shp->shm_ctim = get_seconds();
849+
shp->shm_ctim = ktime_get_real_seconds();
850850
break;
851851
default:
852852
err = -EINVAL;
@@ -1586,7 +1586,7 @@ static int sysvipc_shm_proc_show(struct seq_file *s, void *it)
15861586

15871587
seq_printf(s,
15881588
"%10d %10d %4o " SIZE_SPEC " %5u %5u "
1589-
"%5lu %5u %5u %5u %5u %10lu %10lu %10lu "
1589+
"%5lu %5u %5u %5u %5u %10llu %10llu %10llu "
15901590
SIZE_SPEC " " SIZE_SPEC "\n",
15911591
shp->shm_perm.key,
15921592
shp->shm_perm.id,

0 commit comments

Comments
 (0)