Module Name: src Committed By: apb Date: Wed Jan 4 13:40:53 UTC 2012
Modified Files: src/sys/dev: clockctl.c Log Message: When processing ioctl CLOCKCTL_NTP_ADJTIME, set the return value from ntp_timestatus instead of leaving it uninitialised, and don't use copyout(9) because args->retval is in kernel space, not user space. Previously, running ntpd(8) in unprivileged mode would call libc ntp_adjtime(), which would open /dev/clockctl and call ioctl(CLOCKCTL_NTP_ADJTIME), which would fail with EFAULT. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/clockctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/clockctl.c diff -u src/sys/dev/clockctl.c:1.28 src/sys/dev/clockctl.c:1.29 --- src/sys/dev/clockctl.c:1.28 Sat Oct 3 02:01:12 2009 +++ src/sys/dev/clockctl.c Wed Jan 4 13:40:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: clockctl.c,v 1.28 2009/10/03 02:01:12 elad Exp $ */ +/* $NetBSD: clockctl.c,v 1.29 2012/01/04 13:40:53 apb Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.28 2009/10/03 02:01:12 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.29 2012/01/04 13:40:53 apb Exp $"); #include "opt_ntp.h" #include "opt_compat_netbsd.h" @@ -147,7 +147,6 @@ clockctlioctl( case CLOCKCTL_NTP_ADJTIME: { struct clockctl_ntp_adjtime *args = data; struct timex ntv; - register_t retval; error = copyin(args->tp, &ntv, sizeof(ntv)); if (error) @@ -157,7 +156,7 @@ clockctlioctl( error = copyout(&ntv, args->tp, sizeof(ntv)); if (error == 0) - error = copyout(&retval, &args->retval, sizeof(retval)); + args->retval = ntp_timestatus(); break; } #endif /* NTP */