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
|
||||
|
@ -95,7 +95,7 @@
|
|||
*/
|
||||
|
||||
#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/systm.h>
|
||||
|
@ -1027,23 +1027,14 @@ ibcs2_sys_stime(l, v, retval)
|
|||
struct ibcs2_sys_stime_args /* {
|
||||
syscallarg(long *) timep;
|
||||
} */ *uap = v;
|
||||
struct proc *p = l->l_proc;
|
||||
struct timeval tv;
|
||||
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)));
|
||||
SCARG(&sa, tzp) = NULL;
|
||||
error = copyin((void *)SCARG(uap, timep),
|
||||
(void *)&tvp->tv_sec, sizeof(long));
|
||||
error = copyin(SCARG(uap, timep), &tv.tv_sec, sizeof(long));
|
||||
if (error)
|
||||
return error;
|
||||
tvp->tv_usec = 0;
|
||||
SCARG(&sa, tv) = tvp;
|
||||
if ((error = sys_settimeofday(l, &sa, retval)) != 0)
|
||||
return EPERM;
|
||||
return 0;
|
||||
tv.tv_usec = 0;
|
||||
return settimeofday1(&tv, false, NULL, l, true);
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#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/systm.h>
|
||||
|
@ -235,58 +235,24 @@ osf1_sys_settimeofday(l, v, retval)
|
|||
register_t *retval;
|
||||
{
|
||||
struct osf1_sys_settimeofday_args *uap = v;
|
||||
struct proc *p = l->l_proc;
|
||||
struct sys_settimeofday_args a;
|
||||
struct osf1_timeval otv;
|
||||
struct osf1_timezone otz;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
struct timeval tv, *tvp;
|
||||
int error = 0;
|
||||
void *sg;
|
||||
|
||||
sg = stackgap_init(p, 0);
|
||||
if (SCARG(uap, tv) == NULL)
|
||||
SCARG(&a, tv) = NULL;
|
||||
tvp = NULL;
|
||||
else {
|
||||
SCARG(&a, tv) = stackgap_alloc(p, &sg, sizeof tv);
|
||||
|
||||
/* get the OSF/1 timeval argument */
|
||||
error = copyin((void *)SCARG(uap, tv),
|
||||
(void *)&otv, sizeof otv);
|
||||
if (error == 0) {
|
||||
error = copyin(SCARG(uap, tv), &otv, sizeof otv);
|
||||
if (error != 0)
|
||||
return error;
|
||||
|
||||
/* fill in and copy out the NetBSD timeval */
|
||||
memset(&tv, 0, sizeof tv);
|
||||
tv.tv_sec = otv.tv_sec;
|
||||
tv.tv_usec = otv.tv_usec;
|
||||
|
||||
error = copyout((void *)&tv,
|
||||
__UNCONST(SCARG(&a, tv)), sizeof tv);
|
||||
}
|
||||
tv.tv_sec = otv.tv_sec;
|
||||
tv.tv_usec = otv.tv_usec;
|
||||
tvp = &tv;
|
||||
}
|
||||
|
||||
if (SCARG(uap, tzp) == NULL)
|
||||
SCARG(&a, tzp) = NULL;
|
||||
else {
|
||||
SCARG(&a, tzp) = stackgap_alloc(p, &sg, sizeof tz);
|
||||
/* NetBSD ignores the timezone field */
|
||||
|
||||
/* get the OSF/1 timeval argument */
|
||||
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);
|
||||
return settimeofday1(tvp, false, (const void *)SCARG(uap, tzp), l, true);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
|
||||
#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)
|
||||
#include "opt_nfsserver.h"
|
||||
|
@ -118,10 +118,7 @@ sunos_sys_stime(l, v, retval)
|
|||
register_t *retval;
|
||||
{
|
||||
struct sunos_sys_stime_args *uap = v;
|
||||
struct sys_settimeofday_args ap;
|
||||
struct proc *p = l->l_proc;
|
||||
void *sg = stackgap_init(p, 0);
|
||||
struct timeval tv, *sgtvp;
|
||||
struct timeval tv;
|
||||
int error;
|
||||
|
||||
error = copyin(SCARG(uap, tp), &tv.tv_sec, sizeof(tv.tv_sec));
|
||||
|
@ -129,14 +126,7 @@ sunos_sys_stime(l, v, retval)
|
|||
return error;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
SCARG(&ap, tv) = sgtvp = stackgap_alloc(p, &sg, sizeof(struct timeval));
|
||||
SCARG(&ap, tzp) = NULL;
|
||||
|
||||
error = copyout(&tv, sgtvp, sizeof(struct timeval));
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return sys_settimeofday(l, &ap, retval);
|
||||
return settimeofday1(&tv, false, NULL, l, true);
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -41,10 +41,10 @@
|
|||
* Typedefs for pointer-types.
|
||||
*/
|
||||
/* stime() */
|
||||
typedef u_int32_t sunos32_time_tp;
|
||||
typedef netbsd32_pointer_t sunos32_time_tp;
|
||||
|
||||
/* statfs(), fstatfs() */
|
||||
typedef u_int32_t sunos32_statfsp_t;
|
||||
typedef netbsd32_pointer_t sunos32_statfsp_t;
|
||||
|
||||
/* ustat() */
|
||||
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 */
|
||||
|
||||
/*
|
||||
|
@ -79,7 +79,7 @@
|
|||
*/
|
||||
|
||||
#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
|
||||
|
||||
|
@ -181,27 +181,17 @@ sunos32_sys_stime(l, v, retval)
|
|||
struct sunos32_sys_stime_args /* {
|
||||
syscallarg(sunos32_time_tp) tp;
|
||||
} */ *uap = v;
|
||||
struct proc *p = l->l_proc;
|
||||
struct sys_settimeofday_args ap;
|
||||
void *sg = stackgap_init(p, 0);
|
||||
struct netbsd32_timeval ntv;
|
||||
struct timeval tv, *sgtvp;
|
||||
struct timeval tv;
|
||||
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)
|
||||
return error;
|
||||
tv.tv_sec = ntv.tv_sec;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
SCARG(&ap, tv) = sgtvp = stackgap_alloc(p, &sg, sizeof(struct timeval));
|
||||
SCARG(&ap, tzp) = NULL;
|
||||
|
||||
error = copyout(&tv, sgtvp, sizeof(struct timeval));
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return sys_settimeofday(l, &ap, retval);
|
||||
return settimeofday1(&tv, false, NULL, l, true);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1261,7 +1251,7 @@ sunos32_sys_statfs(l, v, retval)
|
|||
if ((error = VFS_STATVFS(mp, sp, l)) != 0)
|
||||
return (error);
|
||||
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
|
||||
|
@ -1288,7 +1278,7 @@ sunos32_sys_fstatfs(l, v, retval)
|
|||
if ((error = VFS_STATVFS(mp, sp, l)) != 0)
|
||||
goto out;
|
||||
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:
|
||||
FILE_UNUSE(fp, l);
|
||||
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.
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#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"
|
||||
|
||||
|
@ -83,7 +83,7 @@ clockctlioctl(
|
|||
struct clockctl_settimeofday *args =
|
||||
(struct clockctl_settimeofday *)data;
|
||||
|
||||
error = settimeofday1(args->tv, args->tzp, l->l_proc);
|
||||
error = settimeofday1(args->tv, true, args->tzp, l, false);
|
||||
if (error)
|
||||
return (error);
|
||||
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.
|
||||
|
@ -68,7 +68,7 @@
|
|||
*/
|
||||
|
||||
#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/resourcevar.h>
|
||||
|
@ -457,39 +457,46 @@ sys_settimeofday(struct lwp *l, void *v, register_t *retval)
|
|||
syscallarg(const struct timeval *) tv;
|
||||
syscallarg(const void *) tzp; really "const struct timezone *"
|
||||
} */ *uap = v;
|
||||
int error;
|
||||
|
||||
if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_TIME,
|
||||
KAUTH_REQ_SYSTEM_TIME_SYSTEM, NULL, NULL, NULL)) != 0)
|
||||
return (error);
|
||||
|
||||
return settimeofday1(SCARG(uap, tv), SCARG(uap, tzp), l->l_proc);
|
||||
return settimeofday1(SCARG(uap, tv), true, SCARG(uap, tzp), l, true);
|
||||
}
|
||||
|
||||
int
|
||||
settimeofday1(const struct timeval *utv, const struct timezone *utzp,
|
||||
struct proc *p)
|
||||
settimeofday1(const struct timeval *utv, bool userspace,
|
||||
const void *utzp, struct lwp *l, bool check_kauth)
|
||||
{
|
||||
struct timeval atv;
|
||||
struct timespec ts;
|
||||
int error;
|
||||
|
||||
/* 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
|
||||
* obsolete program would try to set it, so we log a warning.
|
||||
*/
|
||||
if (utzp)
|
||||
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)
|
||||
return 0;
|
||||
|
||||
if ((error = copyin(utv, &atv, sizeof(atv))) != 0)
|
||||
return error;
|
||||
TIMEVAL_TO_TIMESPEC(&atv, &ts);
|
||||
return settime(p, &ts);
|
||||
if (userspace) {
|
||||
if ((error = copyin(utv, &atv, sizeof(atv))) != 0)
|
||||
return error;
|
||||
utv = &atv;
|
||||
}
|
||||
|
||||
TIMEVAL_TO_TIMESPEC(utv, &ts);
|
||||
return settime(l->l_proc, &ts);
|
||||
}
|
||||
|
||||
#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.
|
||||
|
@ -182,8 +182,8 @@ int ppsratecheck(struct timeval *, int *, int);
|
|||
int ratecheck(struct timeval *, const struct timeval *);
|
||||
void realtimerexpire(void *);
|
||||
int settime(struct proc *p, struct timespec *);
|
||||
int settimeofday1(const struct timeval *, const struct timezone *,
|
||||
struct proc *);
|
||||
int settimeofday1(const struct timeval *, bool,
|
||||
const void *, struct lwp *, bool);
|
||||
int timer_create1(timer_t *, clockid_t, struct sigevent *, copyin_t,
|
||||
struct lwp *);
|
||||
void timer_gettime(struct ptimer *, struct itimerval *);
|
||||
|
|
Loading…
Reference in New Issue