All of lore.kernel.org
 help / color / mirror / Atom feed
From: Deepa Dinamani <deepa.kernel@gmail.com>
To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, y2038@lists.linaro.org
Subject: [PATCH 1/6] ipc: Make sys_semtimedop() y2038 safe
Date: Fri, 28 Jul 2017 11:06:06 -0700	[thread overview]
Message-ID: <20170728180611.11249-2-deepa.kernel@gmail.com> (raw)
In-Reply-To: <20170728180611.11249-1-deepa.kernel@gmail.com>

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>
---
 ipc/sem.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index 8b3b40c54a58..b41cd00d104c 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1861,7 +1861,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;
@@ -1897,7 +1897,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;
@@ -2116,8 +2116,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);
 	}
@@ -2130,8 +2130,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);
 	}
-- 
2.11.0

  reply	other threads:[~2017-07-28 18:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-28 18:06 Deepa Dinamani
2017-07-28 18:06 ` Deepa Dinamani [this message]
2017-07-28 18:06 ` [PATCH 2/6] ipc: mqueue: Replace timespec with timespec64 Deepa Dinamani
2017-07-28 18:06 ` [PATCH 3/6] ipc: msg: Make msg_queue timestamps y2038 safe Deepa Dinamani
2017-07-28 18:06 ` [PATCH 4/6] ipc: sem: Make sem_array " Deepa Dinamani
2017-07-28 18:06 ` [PATCH 5/6] ipc: shm: Make shmid_kernel " Deepa Dinamani
2017-07-28 18:06 ` [PATCH 6/6] utimes: Make utimes " Deepa Dinamani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170728180611.11249-2-deepa.kernel@gmail.com \
    --to=deepa.kernel@gmail.com \
    --cc=arnd@arndb.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.