]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - ipc/sem.c
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
[linux.git] / ipc / sem.c
index 06be75d9217ace222500b2ebfa276bdee524f6e3..cfd94d48a9aa7ad719ed17e2e9f1a2d53ca028ee 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -70,6 +70,7 @@
  *   The worst-case behavior is nevertheless O(N^2) for N wakeups.
  */
 
+#include <linux/compat.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/init.h>
@@ -104,7 +105,7 @@ struct sem {
                                        /* that alter the semaphore */
        struct list_head pending_const; /* pending single-sop operations */
                                        /* that do not alter the semaphore*/
-       time_t  sem_otime;      /* candidate for sem_otime */
+       time64_t         sem_otime;     /* candidate for sem_otime */
 } ____cacheline_aligned_in_smp;
 
 /* One sem_array data structure for each set of semaphores in the system. */
@@ -984,10 +985,10 @@ static int update_queue(struct sem_array *sma, int semnum, struct wake_q_head *w
 static void set_semotime(struct sem_array *sma, struct sembuf *sops)
 {
        if (sops == NULL) {
-               sma->sems[0].sem_otime = get_seconds();
+               sma->sems[0].sem_otime = ktime_get_real_seconds();
        } else {
                sma->sems[sops[0].sem_num].sem_otime =
-                                                       get_seconds();
+                                               ktime_get_real_seconds();
        }
 }
 
@@ -1214,6 +1215,7 @@ static int semctl_stat(struct ipc_namespace *ns, int semid,
                         int cmd, struct semid64_ds *semid64)
 {
        struct sem_array *sma;
+       time64_t semotime;
        int id = 0;
        int err;
 
@@ -1257,8 +1259,13 @@ static int semctl_stat(struct ipc_namespace *ns, int semid,
        }
 
        kernel_to_ipc64_perm(&sma->sem_perm, &semid64->sem_perm);
-       semid64->sem_otime = get_semotime(sma);
+       semotime = get_semotime(sma);
+       semid64->sem_otime = semotime;
        semid64->sem_ctime = sma->sem_ctime;
+#ifndef CONFIG_64BIT
+       semid64->sem_otime_high = semotime >> 32;
+       semid64->sem_ctime_high = sma->sem_ctime >> 32;
+#endif
        semid64->sem_nsems = sma->sem_nsems;
 
        ipc_unlock_object(&sma->sem_perm);
@@ -1704,8 +1711,10 @@ static int copy_compat_semid_to_user(void __user *buf, struct semid64_ds *in,
                struct compat_semid64_ds v;
                memset(&v, 0, sizeof(v));
                to_compat_ipc64_perm(&v.sem_perm, &in->sem_perm);
-               v.sem_otime = in->sem_otime;
-               v.sem_ctime = in->sem_ctime;
+               v.sem_otime      = lower_32_bits(in->sem_otime);
+               v.sem_otime_high = upper_32_bits(in->sem_otime);
+               v.sem_ctime      = lower_32_bits(in->sem_ctime);
+               v.sem_ctime_high = upper_32_bits(in->sem_ctime);
                v.sem_nsems = in->sem_nsems;
                return copy_to_user(buf, &v, sizeof(v));
        } else {
@@ -2168,7 +2177,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
 }
 
 long ksys_semtimedop(int semid, struct sembuf __user *tsops,
-                    unsigned int nsops, const struct timespec __user *timeout)
+                    unsigned int nsops, const struct __kernel_timespec __user *timeout)
 {
        if (timeout) {
                struct timespec64 ts;
@@ -2180,12 +2189,12 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops,
 }
 
 SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
-               unsigned int, nsops, const struct timespec __user *, timeout)
+               unsigned int, nsops, const struct __kernel_timespec __user *, timeout)
 {
        return ksys_semtimedop(semid, tsops, nsops, timeout);
 }
 
-#ifdef CONFIG_COMPAT
+#ifdef CONFIG_COMPAT_32BIT_TIME
 long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
                            unsigned int nsops,
                            const struct compat_timespec __user *timeout)