Skip to content

Commit

Permalink
ipc: Make sys_semtimedop() y2038 safe
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
deepa-hub authored and Al Viro committed Sep 4, 2017
1 parent 8ac72a4 commit 3ef56dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ipc/sem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
}

static long do_semtimedop(int semid, struct sembuf __user *tsops,
unsigned nsops, const struct timespec *timeout)
unsigned nsops, const struct timespec64 *timeout)
{
int error = -EINVAL;
struct sem_array *sma;
Expand Down Expand Up @@ -1892,7 +1892,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
error = -EINVAL;
goto out_free;
}
jiffies_left = timespec_to_jiffies(timeout);
jiffies_left = timespec64_to_jiffies(timeout);
}

max = 0;
Expand Down Expand Up @@ -2111,8 +2111,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
unsigned, nsops, const struct timespec __user *, timeout)
{
if (timeout) {
struct timespec ts;
if (copy_from_user(&ts, timeout, sizeof(*timeout)))
struct timespec64 ts;
if (get_timespec64(&ts, timeout))
return -EFAULT;
return do_semtimedop(semid, tsops, nsops, &ts);
}
Expand All @@ -2125,8 +2125,8 @@ COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
const struct compat_timespec __user *, timeout)
{
if (timeout) {
struct timespec ts;
if (compat_get_timespec(&ts, timeout))
struct timespec64 ts;
if (compat_get_timespec64(&ts, timeout))
return -EFAULT;
return do_semtimedop(semid, tsems, nsops, &ts);
}
Expand Down

0 comments on commit 3ef56dc

Please sign in to comment.