Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/linux/common Put suser check in the right functio...



details:   https://anonhg.NetBSD.org/src/rev/3789e02a84fe
branches:  trunk
changeset: 355437:3789e02a84fe
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Jul 29 02:31:22 2017 +0000

description:
Put suser check in the right function: settimeofday, not gettimeofday.

While here, remove wrong comment.

Noted by kre@.

diffstat:

 sys/compat/linux/common/linux_time.c |  14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diffs (43 lines):

diff -r 28cb51a18476 -r 3789e02a84fe sys/compat/linux/common/linux_time.c
--- a/sys/compat/linux/common/linux_time.c      Sat Jul 29 02:21:30 2017 +0000
+++ b/sys/compat/linux/common/linux_time.c      Sat Jul 29 02:31:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_time.c,v 1.38 2017/07/29 01:14:59 riastradh Exp $ */
+/*     $NetBSD: linux_time.c,v 1.39 2017/07/29 02:31:22 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.38 2017/07/29 01:14:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.39 2017/07/29 02:31:22 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/ucred.h>
@@ -79,9 +79,6 @@
        }
 
        if (SCARG(uap, tzp)) {
-               if (kauth_authorize_generic(kauth_cred_get(),
-                       KAUTH_GENERIC_ISSUSER, NULL) != 0)
-                       return (EPERM);
                error = copyout(&linux_sys_tz, SCARG(uap, tzp), sizeof(linux_sys_tz));
                if (error)
                        return (error);
@@ -105,11 +102,10 @@
                        return (error);
        }
 
-       /*
-        * If user is not the superuser, we returned
-        * after the sys_settimeofday() call.
-        */
        if (SCARG(uap, tzp)) {
+               if (kauth_authorize_generic(kauth_cred_get(),
+                       KAUTH_GENERIC_ISSUSER, NULL) != 0)
+                       return (EPERM);
                error = copyin(SCARG(uap, tzp), &linux_sys_tz, sizeof(linux_sys_tz));
                if (error)
                        return (error);



Home | Main Index | Thread Index | Old Index