Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 fix these *stat routines: don't pass a k...
details: https://anonhg.NetBSD.org/src/rev/feddd9d4ed48
branches: trunk
changeset: 783183:feddd9d4ed48
user: chs <chs%NetBSD.org@localhost>
date: Mon Dec 10 02:21:58 2012 +0000
description:
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.
diffstat:
sys/compat/netbsd32/netbsd32_compat_12.c | 73 ++++++++++++++-----------------
1 files changed, 33 insertions(+), 40 deletions(-)
diffs (132 lines):
diff -r 0f95336ca30c -r feddd9d4ed48 sys/compat/netbsd32/netbsd32_compat_12.c
--- a/sys/compat/netbsd32/netbsd32_compat_12.c Mon Dec 10 02:03:45 2012 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_12.c Mon Dec 10 02:21:58 2012 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
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
Home |
Main Index |
Thread Index |
Old Index