Module Name: src
Committed By: maxv
Date: Wed Jan 1 09:17:45 UTC 2020
Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_43.c
Log Message:
Fix sizeof mismatch in copyin. This leads to a user-triggerable stack
overflow. On my test build at least, by luck, the compiler orders the
variables in a way that the overflow hits only local structures which
haven't yet been initialized and used, so the overflow is harmless.
Very easily seeable with kASan - just invoke the syscall from a 32bit
binary.
To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/compat/netbsd32/netbsd32_compat_43.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_43.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_43.c:1.58 src/sys/compat/netbsd32/netbsd32_compat_43.c:1.59
--- src/sys/compat/netbsd32/netbsd32_compat_43.c:1.58 Fri Aug 23 13:59:45 2019
+++ src/sys/compat/netbsd32/netbsd32_compat_43.c Wed Jan 1 09:17:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_43.c,v 1.58 2019/08/23 13:59:45 maxv Exp $ */
+/* $NetBSD: netbsd32_compat_43.c,v 1.59 2020/01/01 09:17:45 maxv Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.58 2019/08/23 13:59:45 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.59 2020/01/01 09:17:45 maxv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_43.h"
@@ -433,7 +433,7 @@ compat_43_netbsd32_orecvmsg(struct lwp *
struct iovec *iov, aiov[UIO_SMALLIOV];
int error;
- error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
+ error = copyin(SCARG_P32(uap, msg), &omsg, sizeof(omsg));
if (error)
return (error);
@@ -518,7 +518,7 @@ compat_43_netbsd32_osendmsg(struct lwp *
struct sockaddr *sa;
int error;
- error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
+ error = copyin(SCARG_P32(uap, msg), &omsg, sizeof(omsg));
if (error != 0)
return (error);