Module Name:    src
Committed By:   christos
Date:           Mon Oct 27 19:10:21 UTC 2014

Modified Files:
        src/sys/compat/netbsd32: netbsd32_compat_50.c

Log Message:
fix multiple mistakes:
- error from copyout was ignored
- the wrong size was specified in copyin
- missing locking.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/compat/netbsd32/netbsd32_compat_50.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/compat/netbsd32/netbsd32_compat_50.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_50.c:1.27 src/sys/compat/netbsd32/netbsd32_compat_50.c:1.28
--- src/sys/compat/netbsd32/netbsd32_compat_50.c:1.27	Fri Sep  5 05:21:54 2014
+++ src/sys/compat/netbsd32/netbsd32_compat_50.c	Mon Oct 27 15:10:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_50.c,v 1.27 2014/09/05 09:21:54 matt Exp $	*/
+/*	$NetBSD: netbsd32_compat_50.c,v 1.28 2014/10/27 19:10:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.27 2014/09/05 09:21:54 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.28 2014/10/27 19:10:21 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sysv.h"
@@ -247,30 +247,31 @@ compat_50_netbsd32_adjtime(struct lwp *l
 		return (error);
 
 	if (SCARG_P32(uap, olddelta)) {
+		mutex_spin_enter(&timecounter_lock);
 		atv.tv_sec = time_adjtime / 1000000;
 		atv.tv_usec = time_adjtime % 1000000;
 		if (atv.tv_usec < 0) {
 			atv.tv_usec += 1000000;
 			atv.tv_sec--;
 		}
-		(void) copyout(&atv,
-			       SCARG_P32(uap, olddelta), 
-			       sizeof(atv));
+		mutex_spin_exit(&timecounter_lock);
+
+		error = copyout(&atv, SCARG_P32(uap, olddelta), sizeof(atv));
 		if (error)
 			return (error);
 	}
 	
 	if (SCARG_P32(uap, delta)) {
-		error = copyin(SCARG_P32(uap, delta), &atv,
-			       sizeof(struct timeval));
+		error = copyin(SCARG_P32(uap, delta), &atv, sizeof(atv));
 		if (error)
 			return (error);
 
+		mutex_spin_enter(&timecounter_lock);
 		time_adjtime = (int64_t)atv.tv_sec * 1000000 + atv.tv_usec;
-
 		if (time_adjtime)
 			/* We need to save the system time during shutdown */
 			time_adjusted |= 1;
+		mutex_spin_exit(&timecounter_lock);
 	}
 
 	return 0;

Reply via email to