]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/sys.c
NET: dwmac: Make dwmac reset unconditional
[karo-tx-linux.git] / kernel / sys.c
index dab1a0658a92b7903a9b0318ee89429e18df2339..2855ee73acd0ef9f62699ff669659e045df84422 100644 (file)
@@ -886,7 +886,7 @@ SYSCALL_DEFINE0(getegid)
        return from_kgid_munged(current_user_ns(), current_egid());
 }
 
-void do_sys_times(struct tms *tms)
+static void do_sys_times(struct tms *tms)
 {
        u64 tgutime, tgstime, cutime, cstime;
 
@@ -912,6 +912,32 @@ SYSCALL_DEFINE1(times, struct tms __user *, tbuf)
        return (long) jiffies_64_to_clock_t(get_jiffies_64());
 }
 
+#ifdef CONFIG_COMPAT
+static compat_clock_t clock_t_to_compat_clock_t(clock_t x)
+{
+       return compat_jiffies_to_clock_t(clock_t_to_jiffies(x));
+}
+
+COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf)
+{
+       if (tbuf) {
+               struct tms tms;
+               struct compat_tms tmp;
+
+               do_sys_times(&tms);
+               /* Convert our struct tms to the compat version. */
+               tmp.tms_utime = clock_t_to_compat_clock_t(tms.tms_utime);
+               tmp.tms_stime = clock_t_to_compat_clock_t(tms.tms_stime);
+               tmp.tms_cutime = clock_t_to_compat_clock_t(tms.tms_cutime);
+               tmp.tms_cstime = clock_t_to_compat_clock_t(tms.tms_cstime);
+               if (copy_to_user(tbuf, &tmp, sizeof(tmp)))
+                       return -EFAULT;
+       }
+       force_successful_syscall_return();
+       return compat_jiffies_to_clock_t(jiffies);
+}
+#endif
+
 /*
  * This needs some heavy checking ...
  * I just haven't the stomach for it. I also don't fully
@@ -1306,6 +1332,54 @@ SYSCALL_DEFINE2(getrlimit, unsigned int, resource, struct rlimit __user *, rlim)
        return ret;
 }
 
+#ifdef CONFIG_COMPAT
+
+COMPAT_SYSCALL_DEFINE2(setrlimit, unsigned int, resource,
+                      struct compat_rlimit __user *, rlim)
+{
+       struct rlimit r;
+       struct compat_rlimit r32;
+
+       if (copy_from_user(&r32, rlim, sizeof(struct compat_rlimit)))
+               return -EFAULT;
+
+       if (r32.rlim_cur == COMPAT_RLIM_INFINITY)
+               r.rlim_cur = RLIM_INFINITY;
+       else
+               r.rlim_cur = r32.rlim_cur;
+       if (r32.rlim_max == COMPAT_RLIM_INFINITY)
+               r.rlim_max = RLIM_INFINITY;
+       else
+               r.rlim_max = r32.rlim_max;
+       return do_prlimit(current, resource, &r, NULL);
+}
+
+COMPAT_SYSCALL_DEFINE2(getrlimit, unsigned int, resource,
+                      struct compat_rlimit __user *, rlim)
+{
+       struct rlimit r;
+       int ret;
+
+       ret = do_prlimit(current, resource, NULL, &r);
+       if (!ret) {
+               struct compat_rlimit r32;
+               if (r.rlim_cur > COMPAT_RLIM_INFINITY)
+                       r32.rlim_cur = COMPAT_RLIM_INFINITY;
+               else
+                       r32.rlim_cur = r.rlim_cur;
+               if (r.rlim_max > COMPAT_RLIM_INFINITY)
+                       r32.rlim_max = COMPAT_RLIM_INFINITY;
+               else
+                       r32.rlim_max = r.rlim_max;
+
+               if (copy_to_user(rlim, &r32, sizeof(struct compat_rlimit)))
+                       return -EFAULT;
+       }
+       return ret;
+}
+
+#endif
+
 #ifdef __ARCH_WANT_SYS_OLD_GETRLIMIT
 
 /*
@@ -1328,6 +1402,30 @@ SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
        return copy_to_user(rlim, &x, sizeof(x)) ? -EFAULT : 0;
 }
 
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
+                      struct compat_rlimit __user *, rlim)
+{
+       struct rlimit r;
+
+       if (resource >= RLIM_NLIMITS)
+               return -EINVAL;
+
+       task_lock(current->group_leader);
+       r = current->signal->rlim[resource];
+       task_unlock(current->group_leader);
+       if (r.rlim_cur > 0x7FFFFFFF)
+               r.rlim_cur = 0x7FFFFFFF;
+       if (r.rlim_max > 0x7FFFFFFF)
+               r.rlim_max = 0x7FFFFFFF;
+
+       if (put_user(r.rlim_cur, &rlim->rlim_cur) ||
+           put_user(r.rlim_max, &rlim->rlim_max))
+               return -EFAULT;
+       return 0;
+}
+#endif
+
 #endif
 
 static inline bool rlim64_is_infinity(__u64 rlim64)
@@ -2262,7 +2360,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
        case PR_GET_THP_DISABLE:
                if (arg2 || arg3 || arg4 || arg5)
                        return -EINVAL;
-               error = !!(me->mm->def_flags & VM_NOHUGEPAGE);
+               error = !!test_bit(MMF_DISABLE_THP, &me->mm->flags);
                break;
        case PR_SET_THP_DISABLE:
                if (arg3 || arg4 || arg5)
@@ -2270,9 +2368,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
                if (down_write_killable(&me->mm->mmap_sem))
                        return -EINTR;
                if (arg2)
-                       me->mm->def_flags |= VM_NOHUGEPAGE;
+                       set_bit(MMF_DISABLE_THP, &me->mm->flags);
                else
-                       me->mm->def_flags &= ~VM_NOHUGEPAGE;
+                       clear_bit(MMF_DISABLE_THP, &me->mm->flags);
                up_write(&me->mm->mmap_sem);
                break;
        case PR_MPX_ENABLE_MANAGEMENT: