Skip to content

Commit 3ef56dc

Browse files
deepa-hubAl Viro
authored andcommitted
ipc: Make sys_semtimedop() y2038 safe
struct timespec is not y2038 safe on 32 bit machines. Replace timespec with y2038 safe struct timespec64. Note that the patch only changes the internals without modifying the syscall interface. This will be part of a separate 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 8ac72a4 commit 3ef56dc

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎ipc/sem.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
18561856
}
18571857

18581858
static long do_semtimedop(int semid, struct sembuf __user *tsops,
1859-
unsigned nsops, const struct timespec *timeout)
1859+
unsigned nsops, const struct timespec64 *timeout)
18601860
{
18611861
int error = -EINVAL;
18621862
struct sem_array *sma;
@@ -1892,7 +1892,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
18921892
error = -EINVAL;
18931893
goto out_free;
18941894
}
1895-
jiffies_left = timespec_to_jiffies(timeout);
1895+
jiffies_left = timespec64_to_jiffies(timeout);
18961896
}
18971897

18981898
max = 0;
@@ -2111,8 +2111,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
21112111
unsigned, nsops, const struct timespec __user *, timeout)
21122112
{
21132113
if (timeout) {
2114-
struct timespec ts;
2115-
if (copy_from_user(&ts, timeout, sizeof(*timeout)))
2114+
struct timespec64 ts;
2115+
if (get_timespec64(&ts, timeout))
21162116
return -EFAULT;
21172117
return do_semtimedop(semid, tsops, nsops, &ts);
21182118
}
@@ -2125,8 +2125,8 @@ COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
21252125
const struct compat_timespec __user *, timeout)
21262126
{
21272127
if (timeout) {
2128-
struct timespec ts;
2129-
if (compat_get_timespec(&ts, timeout))
2128+
struct timespec64 ts;
2129+
if (compat_get_timespec64(&ts, timeout))
21302130
return -EFAULT;
21312131
return do_semtimedop(semid, tsems, nsops, &ts);
21322132
}

0 commit comments

Comments
 (0)