Change interface to settimeofday1() so that it can also be used from
compat code in order to avoid the stackgap.
This commit is contained in:
parent
dd490a6f18
commit
ef3fdc4a07
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: ibcs2_misc.c,v 1.88 2007/05/12 18:10:20 dsl Exp $ */
|
/* $NetBSD: ibcs2_misc.c,v 1.89 2007/05/12 20:27:18 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.88 2007/05/12 18:10:20 dsl Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.89 2007/05/12 20:27:18 dsl Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -1027,23 +1027,14 @@ ibcs2_sys_stime(l, v, retval)
|
||||||
struct ibcs2_sys_stime_args /* {
|
struct ibcs2_sys_stime_args /* {
|
||||||
syscallarg(long *) timep;
|
syscallarg(long *) timep;
|
||||||
} */ *uap = v;
|
} */ *uap = v;
|
||||||
struct proc *p = l->l_proc;
|
struct timeval tv;
|
||||||
int error;
|
int error;
|
||||||
struct sys_settimeofday_args sa;
|
|
||||||
void *sg = stackgap_init(p, 0);
|
|
||||||
struct timeval *tvp;
|
|
||||||
|
|
||||||
tvp = stackgap_alloc(p, &sg, sizeof(*SCARG(&sa, tv)));
|
error = copyin(SCARG(uap, timep), &tv.tv_sec, sizeof(long));
|
||||||
SCARG(&sa, tzp) = NULL;
|
|
||||||
error = copyin((void *)SCARG(uap, timep),
|
|
||||||
(void *)&tvp->tv_sec, sizeof(long));
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
tvp->tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
SCARG(&sa, tv) = tvp;
|
return settimeofday1(&tv, false, NULL, l, true);
|
||||||
if ((error = sys_settimeofday(l, &sa, retval)) != 0)
|
|
||||||
return EPERM;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: osf1_time.c,v 1.12 2007/03/04 06:01:28 christos Exp $ */
|
/* $NetBSD: osf1_time.c,v 1.13 2007/05/12 20:27:40 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: osf1_time.c,v 1.12 2007/03/04 06:01:28 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: osf1_time.c,v 1.13 2007/05/12 20:27:40 dsl Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -235,58 +235,24 @@ osf1_sys_settimeofday(l, v, retval)
|
||||||
register_t *retval;
|
register_t *retval;
|
||||||
{
|
{
|
||||||
struct osf1_sys_settimeofday_args *uap = v;
|
struct osf1_sys_settimeofday_args *uap = v;
|
||||||
struct proc *p = l->l_proc;
|
|
||||||
struct sys_settimeofday_args a;
|
|
||||||
struct osf1_timeval otv;
|
struct osf1_timeval otv;
|
||||||
struct osf1_timezone otz;
|
struct timeval tv, *tvp;
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
void *sg;
|
|
||||||
|
|
||||||
sg = stackgap_init(p, 0);
|
|
||||||
if (SCARG(uap, tv) == NULL)
|
if (SCARG(uap, tv) == NULL)
|
||||||
SCARG(&a, tv) = NULL;
|
tvp = NULL;
|
||||||
else {
|
else {
|
||||||
SCARG(&a, tv) = stackgap_alloc(p, &sg, sizeof tv);
|
|
||||||
|
|
||||||
/* get the OSF/1 timeval argument */
|
/* get the OSF/1 timeval argument */
|
||||||
error = copyin((void *)SCARG(uap, tv),
|
error = copyin(SCARG(uap, tv), &otv, sizeof otv);
|
||||||
(void *)&otv, sizeof otv);
|
if (error != 0)
|
||||||
if (error == 0) {
|
return error;
|
||||||
|
|
||||||
/* fill in and copy out the NetBSD timeval */
|
tv.tv_sec = otv.tv_sec;
|
||||||
memset(&tv, 0, sizeof tv);
|
tv.tv_usec = otv.tv_usec;
|
||||||
tv.tv_sec = otv.tv_sec;
|
tvp = &tv;
|
||||||
tv.tv_usec = otv.tv_usec;
|
|
||||||
|
|
||||||
error = copyout((void *)&tv,
|
|
||||||
__UNCONST(SCARG(&a, tv)), sizeof tv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SCARG(uap, tzp) == NULL)
|
/* NetBSD ignores the timezone field */
|
||||||
SCARG(&a, tzp) = NULL;
|
|
||||||
else {
|
|
||||||
SCARG(&a, tzp) = stackgap_alloc(p, &sg, sizeof tz);
|
|
||||||
|
|
||||||
/* get the OSF/1 timeval argument */
|
return settimeofday1(tvp, false, (const void *)SCARG(uap, tzp), l, true);
|
||||||
error = copyin((void *)SCARG(uap, tzp),
|
|
||||||
(void *)&otz, sizeof otz);
|
|
||||||
if (error == 0) {
|
|
||||||
|
|
||||||
/* fill in and copy out the NetBSD timezone */
|
|
||||||
memset(&tz, 0, sizeof tz);
|
|
||||||
tz.tz_minuteswest = otz.tz_minuteswest;
|
|
||||||
tz.tz_dsttime = otz.tz_dsttime;
|
|
||||||
|
|
||||||
error = copyout((void *)&tz,
|
|
||||||
__UNCONST(SCARG(&a, tzp)), sizeof tz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error == 0)
|
|
||||||
error = sys_settimeofday(l, &a, retval);
|
|
||||||
|
|
||||||
return (error);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: sunos_misc.c,v 1.148 2007/04/28 00:03:37 dogcow Exp $ */
|
/* $NetBSD: sunos_misc.c,v 1.149 2007/05/12 20:27:56 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.148 2007/04/28 00:03:37 dogcow Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.149 2007/05/12 20:27:56 dsl Exp $");
|
||||||
|
|
||||||
#if defined(_KERNEL_OPT)
|
#if defined(_KERNEL_OPT)
|
||||||
#include "opt_nfsserver.h"
|
#include "opt_nfsserver.h"
|
||||||
|
@ -118,10 +118,7 @@ sunos_sys_stime(l, v, retval)
|
||||||
register_t *retval;
|
register_t *retval;
|
||||||
{
|
{
|
||||||
struct sunos_sys_stime_args *uap = v;
|
struct sunos_sys_stime_args *uap = v;
|
||||||
struct sys_settimeofday_args ap;
|
struct timeval tv;
|
||||||
struct proc *p = l->l_proc;
|
|
||||||
void *sg = stackgap_init(p, 0);
|
|
||||||
struct timeval tv, *sgtvp;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = copyin(SCARG(uap, tp), &tv.tv_sec, sizeof(tv.tv_sec));
|
error = copyin(SCARG(uap, tp), &tv.tv_sec, sizeof(tv.tv_sec));
|
||||||
|
@ -129,14 +126,7 @@ sunos_sys_stime(l, v, retval)
|
||||||
return error;
|
return error;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
SCARG(&ap, tv) = sgtvp = stackgap_alloc(p, &sg, sizeof(struct timeval));
|
return settimeofday1(&tv, false, NULL, l, true);
|
||||||
SCARG(&ap, tzp) = NULL;
|
|
||||||
|
|
||||||
error = copyout(&tv, sgtvp, sizeof(struct timeval));
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
return sys_settimeofday(l, &ap, retval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: sunos32.h,v 1.11 2007/04/22 08:29:59 dsl Exp $ */
|
/* $NetBSD: sunos32.h,v 1.12 2007/05/12 20:27:56 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Matthew R. Green
|
* Copyright (c) 2001 Matthew R. Green
|
||||||
|
@ -41,10 +41,10 @@
|
||||||
* Typedefs for pointer-types.
|
* Typedefs for pointer-types.
|
||||||
*/
|
*/
|
||||||
/* stime() */
|
/* stime() */
|
||||||
typedef u_int32_t sunos32_time_tp;
|
typedef netbsd32_pointer_t sunos32_time_tp;
|
||||||
|
|
||||||
/* statfs(), fstatfs() */
|
/* statfs(), fstatfs() */
|
||||||
typedef u_int32_t sunos32_statfsp_t;
|
typedef netbsd32_pointer_t sunos32_statfsp_t;
|
||||||
|
|
||||||
/* ustat() */
|
/* ustat() */
|
||||||
typedef netbsd32_pointer_t sunos32_ustatp_t;
|
typedef netbsd32_pointer_t sunos32_ustatp_t;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: sunos32_misc.c,v 1.48 2007/04/22 08:29:59 dsl Exp $ */
|
/* $NetBSD: sunos32_misc.c,v 1.49 2007/05/12 20:27:56 dsl Exp $ */
|
||||||
/* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
|
/* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.48 2007/04/22 08:29:59 dsl Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.49 2007/05/12 20:27:56 dsl Exp $");
|
||||||
|
|
||||||
#define COMPAT_SUNOS 1
|
#define COMPAT_SUNOS 1
|
||||||
|
|
||||||
|
@ -181,27 +181,17 @@ sunos32_sys_stime(l, v, retval)
|
||||||
struct sunos32_sys_stime_args /* {
|
struct sunos32_sys_stime_args /* {
|
||||||
syscallarg(sunos32_time_tp) tp;
|
syscallarg(sunos32_time_tp) tp;
|
||||||
} */ *uap = v;
|
} */ *uap = v;
|
||||||
struct proc *p = l->l_proc;
|
|
||||||
struct sys_settimeofday_args ap;
|
|
||||||
void *sg = stackgap_init(p, 0);
|
|
||||||
struct netbsd32_timeval ntv;
|
struct netbsd32_timeval ntv;
|
||||||
struct timeval tv, *sgtvp;
|
struct timeval tv;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = copyin((void *)(u_long)SCARG(uap, tp), &ntv.tv_sec, sizeof(ntv.tv_sec));
|
error = copyin(SCARG_P32(uap, tp), &ntv.tv_sec, sizeof(ntv.tv_sec));
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
tv.tv_sec = ntv.tv_sec;
|
tv.tv_sec = ntv.tv_sec;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
SCARG(&ap, tv) = sgtvp = stackgap_alloc(p, &sg, sizeof(struct timeval));
|
return settimeofday1(&tv, false, NULL, l, true);
|
||||||
SCARG(&ap, tzp) = NULL;
|
|
||||||
|
|
||||||
error = copyout(&tv, sgtvp, sizeof(struct timeval));
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
return sys_settimeofday(l, &ap, retval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1261,7 +1251,7 @@ sunos32_sys_statfs(l, v, retval)
|
||||||
if ((error = VFS_STATVFS(mp, sp, l)) != 0)
|
if ((error = VFS_STATVFS(mp, sp, l)) != 0)
|
||||||
return (error);
|
return (error);
|
||||||
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||||
return sunstatfs(sp, (void *)(u_long)SCARG(uap, buf));
|
return sunstatfs(sp, SCARG_P32(uap, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1288,7 +1278,7 @@ sunos32_sys_fstatfs(l, v, retval)
|
||||||
if ((error = VFS_STATVFS(mp, sp, l)) != 0)
|
if ((error = VFS_STATVFS(mp, sp, l)) != 0)
|
||||||
goto out;
|
goto out;
|
||||||
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||||
error = sunstatfs(sp, (void *)(u_long)SCARG(uap, buf));
|
error = sunstatfs(sp, SCARG_P32(uap, buf));
|
||||||
out:
|
out:
|
||||||
FILE_UNUSE(fp, l);
|
FILE_UNUSE(fp, l);
|
||||||
return (error);
|
return (error);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: clockctl.c,v 1.21 2007/03/04 06:01:41 christos Exp $ */
|
/* $NetBSD: clockctl.c,v 1.22 2007/05/12 20:27:13 dsl Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.21 2007/03/04 06:01:41 christos Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.22 2007/05/12 20:27:13 dsl Exp $");
|
||||||
|
|
||||||
#include "opt_ntp.h"
|
#include "opt_ntp.h"
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ clockctlioctl(
|
||||||
struct clockctl_settimeofday *args =
|
struct clockctl_settimeofday *args =
|
||||||
(struct clockctl_settimeofday *)data;
|
(struct clockctl_settimeofday *)data;
|
||||||
|
|
||||||
error = settimeofday1(args->tv, args->tzp, l->l_proc);
|
error = settimeofday1(args->tv, true, args->tzp, l, false);
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern_time.c,v 1.118 2007/03/12 18:18:33 ad Exp $ */
|
/* $NetBSD: kern_time.c,v 1.119 2007/05/12 20:27:57 dsl Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc.
|
* Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc.
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.118 2007/03/12 18:18:33 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.119 2007/05/12 20:27:57 dsl Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
@ -457,39 +457,46 @@ sys_settimeofday(struct lwp *l, void *v, register_t *retval)
|
||||||
syscallarg(const struct timeval *) tv;
|
syscallarg(const struct timeval *) tv;
|
||||||
syscallarg(const void *) tzp; really "const struct timezone *"
|
syscallarg(const void *) tzp; really "const struct timezone *"
|
||||||
} */ *uap = v;
|
} */ *uap = v;
|
||||||
int error;
|
|
||||||
|
|
||||||
if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_TIME,
|
return settimeofday1(SCARG(uap, tv), true, SCARG(uap, tzp), l, true);
|
||||||
KAUTH_REQ_SYSTEM_TIME_SYSTEM, NULL, NULL, NULL)) != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
return settimeofday1(SCARG(uap, tv), SCARG(uap, tzp), l->l_proc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
settimeofday1(const struct timeval *utv, const struct timezone *utzp,
|
settimeofday1(const struct timeval *utv, bool userspace,
|
||||||
struct proc *p)
|
const void *utzp, struct lwp *l, bool check_kauth)
|
||||||
{
|
{
|
||||||
struct timeval atv;
|
struct timeval atv;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/* Verify all parameters before changing time. */
|
/* Verify all parameters before changing time. */
|
||||||
|
|
||||||
|
if (check_kauth) {
|
||||||
|
error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_TIME,
|
||||||
|
KAUTH_REQ_SYSTEM_TIME_SYSTEM, NULL, NULL, NULL);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NetBSD has no kernel notion of time zone, and only an
|
* NetBSD has no kernel notion of time zone, and only an
|
||||||
* obsolete program would try to set it, so we log a warning.
|
* obsolete program would try to set it, so we log a warning.
|
||||||
*/
|
*/
|
||||||
if (utzp)
|
if (utzp)
|
||||||
log(LOG_WARNING, "pid %d attempted to set the "
|
log(LOG_WARNING, "pid %d attempted to set the "
|
||||||
"(obsolete) kernel time zone\n", p->p_pid);
|
"(obsolete) kernel time zone\n", l->l_proc->p_pid);
|
||||||
|
|
||||||
if (utv == NULL)
|
if (utv == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((error = copyin(utv, &atv, sizeof(atv))) != 0)
|
if (userspace) {
|
||||||
return error;
|
if ((error = copyin(utv, &atv, sizeof(atv))) != 0)
|
||||||
TIMEVAL_TO_TIMESPEC(&atv, &ts);
|
return error;
|
||||||
return settime(p, &ts);
|
utv = &atv;
|
||||||
|
}
|
||||||
|
|
||||||
|
TIMEVAL_TO_TIMESPEC(utv, &ts);
|
||||||
|
return settime(l->l_proc, &ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __HAVE_TIMECOUNTER
|
#ifndef __HAVE_TIMECOUNTER
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: timevar.h,v 1.7 2007/02/09 21:55:37 ad Exp $ */
|
/* $NetBSD: timevar.h,v 1.8 2007/05/12 20:27:57 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005 The NetBSD Foundation.
|
* Copyright (c) 2005 The NetBSD Foundation.
|
||||||
|
@ -182,8 +182,8 @@ int ppsratecheck(struct timeval *, int *, int);
|
||||||
int ratecheck(struct timeval *, const struct timeval *);
|
int ratecheck(struct timeval *, const struct timeval *);
|
||||||
void realtimerexpire(void *);
|
void realtimerexpire(void *);
|
||||||
int settime(struct proc *p, struct timespec *);
|
int settime(struct proc *p, struct timespec *);
|
||||||
int settimeofday1(const struct timeval *, const struct timezone *,
|
int settimeofday1(const struct timeval *, bool,
|
||||||
struct proc *);
|
const void *, struct lwp *, bool);
|
||||||
int timer_create1(timer_t *, clockid_t, struct sigevent *, copyin_t,
|
int timer_create1(timer_t *, clockid_t, struct sigevent *, copyin_t,
|
||||||
struct lwp *);
|
struct lwp *);
|
||||||
void timer_gettime(struct ptimer *, struct itimerval *);
|
void timer_gettime(struct ptimer *, struct itimerval *);
|
||||||
|
|
Loading…
Reference in New Issue