Module Name: src
Committed By: chs
Date: Mon Dec 10 02:21:58 UTC 2012
Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_12.c
Log Message:
fix these *stat routines: don't pass a kernel stack buffer
to a function that will try to copyout() to it.
just do both layers of compat translation here.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/compat/netbsd32/netbsd32_compat_12.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_12.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_12.c:1.32 src/sys/compat/netbsd32/netbsd32_compat_12.c:1.33
--- src/sys/compat/netbsd32/netbsd32_compat_12.c:1.32 Fri Jan 30 13:01:36 2009
+++ src/sys/compat/netbsd32/netbsd32_compat_12.c Mon Dec 10 02:21:58 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_12.c,v 1.32 2009/01/30 13:01:36 njoly Exp $ */
+/* $NetBSD: netbsd32_compat_12.c,v 1.33 2012/12/10 02:21:58 chs Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_12.c,v 1.32 2009/01/30 13:01:36 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_12.c,v 1.33 2012/12/10 02:21:58 chs Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -35,11 +35,15 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_com
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/filedesc.h>
#include <sys/mount.h>
#include <sys/mman.h>
+#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/swap.h>
+#include <sys/vfs_syscalls.h>
+
#include <sys/syscallargs.h>
#include <compat/sys/stat.h>
@@ -126,23 +130,19 @@ compat_12_netbsd32_stat12(struct lwp *l,
syscallarg(const netbsd32_charp) path;
syscallarg(netbsd32_stat12p_t) ub;
} */
- struct netbsd32_stat12 *sp32, sb32;
+ struct netbsd32_stat12 sb32;
struct stat12 sb12;
- struct stat12 *sp12 = &sb12;
- struct compat_12_sys_stat_args ua;
- int rv;
-
- NETBSD32TOP_UAP(path, const char);
- SCARG(&ua, ub) = &sb12;
+ struct stat sb;
+ int error;
- rv = compat_12_sys_stat(l, &ua, retval);
- if (rv)
- return (rv);
+ error = do_sys_stat(SCARG_P32(uap, path), FOLLOW, &sb);
+ if (error)
+ return (error);
- sp32 = SCARG_P32(uap, ub);
- netbsd32_stat12_to_netbsd32(sp12, &sb32);
+ compat_12_stat_conv(&sb, &sb12);
+ netbsd32_stat12_to_netbsd32(&sb12, &sb32);
- return (copyout(&sb32, sp32, sizeof sb32));
+ return (copyout(&sb32, SCARG_P32(uap, ub), sizeof sb32));
}
int
@@ -152,22 +152,19 @@ compat_12_netbsd32_fstat12(struct lwp *l
syscallarg(int) fd;
syscallarg(netbsd32_stat12p_t) sb;
} */
- struct netbsd32_stat12 *sp32, sb32;
+ struct netbsd32_stat12 sb32;
struct stat12 sb12;
- struct stat12 *sp12 = &sb12;
- struct compat_12_sys_fstat_args ua;
- int rv;
+ struct stat sb;
+ int error;
- NETBSD32TO64_UAP(fd);
- SCARG(&ua, sb) = &sb12;
- rv = compat_12_sys_fstat(l, &ua, retval);
- if (rv)
- return (rv);
+ error = do_sys_fstat(SCARG(uap, fd), &sb);
+ if (error)
+ return (error);
- sp32 = SCARG_P32(uap, sb);
- netbsd32_stat12_to_netbsd32(sp12, &sb32);
+ compat_12_stat_conv(&sb, &sb12);
+ netbsd32_stat12_to_netbsd32(&sb12, &sb32);
- return (copyout(&sb32, sp32, sizeof sb32));
+ return (copyout(&sb32, SCARG_P32(uap, sb), sizeof sb32));
}
int
@@ -177,23 +174,19 @@ compat_12_netbsd32_lstat12(struct lwp *l
syscallarg(const netbsd32_charp) path;
syscallarg(netbsd32_stat12p_t) ub;
} */
- struct netbsd32_stat12 *sp32, sb32;
+ struct netbsd32_stat12 sb32;
struct stat12 sb12;
- struct stat12 *sp12 = &sb12;
- struct compat_12_sys_lstat_args ua;
- int rv;
-
- NETBSD32TOP_UAP(path, const char);
- SCARG(&ua, ub) = &sb12;
+ struct stat sb;
+ int error;
- rv = compat_12_sys_lstat(l, &ua, retval);
- if (rv)
- return (rv);
+ error = do_sys_stat(SCARG_P32(uap, path), NOFOLLOW, &sb);
+ if (error)
+ return (error);
- sp32 = SCARG_P32(uap, ub);
- netbsd32_stat12_to_netbsd32(sp12, &sb32);
+ compat_12_stat_conv(&sb, &sb12);
+ netbsd32_stat12_to_netbsd32(&sb12, &sb32);
- return (copyout(&sb32, sp32, sizeof sb32));
+ return (copyout(&sb32, SCARG_P32(uap, ub), sizeof sb32));
}
int