From 6681649a730f668723a286f0514f80fe509c785f Mon Sep 17 00:00:00 2001 From: cheloha Date: Wed, 4 Sep 2019 14:27:56 +0000 Subject: gettimeofday, settimeofday(2): limit timezone support For gettimeofday(2), always copy out an empty timezone struct. For settimeofday(2), still copyin(9) the struct but ignore the contents. In gettimeofday(2)'s case we have not changed the original BSD semantics: the kernel only tracks UTC time without an offset for DST, so a zeroed timezone struct is the correct thing to return to the caller. Future work could move these out into libc as stubs for clock_gettime and clock_settime(2). But, definitely a "later" thing, given that we are in beta. Update the manpage to de-emphasize the timezone parameters for these syscalls. Discussed with tedu@, deraadt@, millert@, kettenis@, yasuoka@, jca@, and guenther@. Tested by job@. Ports input from jca@ and sthen@. Manpage input from jca@. ok jca@ deraadt@ --- sys/kern/kern_time.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/kern/kern_time.c') diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 8f1197b7935..31934323f71 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.123 2019/08/03 22:53:45 cheloha Exp $ */ +/* $OpenBSD: kern_time.c,v 1.124 2019/09/04 14:27:55 cheloha Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -323,6 +323,7 @@ sys_gettimeofday(struct proc *p, void *v, register_t *retval) syscallarg(struct timezone *) tzp; } */ *uap = v; struct timeval atv; + static const struct timezone zerotz = { 0, 0 }; struct timeval *tp; struct timezone *tzp; int error = 0; @@ -341,7 +342,7 @@ sys_gettimeofday(struct proc *p, void *v, register_t *retval) #endif } if (tzp) - error = copyout(&tz, tzp, sizeof (tz)); + error = copyout(&zerotz, tzp, sizeof(zerotz)); return (error); } @@ -377,8 +378,7 @@ sys_settimeofday(struct proc *p, void *v, register_t *retval) if ((error = settime(&ts)) != 0) return (error); } - if (tzp) - tz = atz; + return (0); } -- cgit v1.2.3