CVS commit: [netbsd-5] src/sys/compat/linux32/arch/amd64

2015-03-18 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Mar 18 17:21:22 UTC 2015

Modified Files:
src/sys/compat/linux32/arch/amd64 [netbsd-5]: linux32_syscall.h
linux32_syscallargs.h linux32_syscalls.c linux32_sysent.c

Log Message:
regen for ticket 1149


To generate a diff of this commit:
cvs rdiff -u -r1.41.4.1 -r1.41.4.2 \
src/sys/compat/linux32/arch/amd64/linux32_syscall.h \
src/sys/compat/linux32/arch/amd64/linux32_syscallargs.h \
src/sys/compat/linux32/arch/amd64/linux32_syscalls.c \
src/sys/compat/linux32/arch/amd64/linux32_sysent.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/linux32/arch/amd64/linux32_syscall.h
diff -u src/sys/compat/linux32/arch/amd64/linux32_syscall.h:1.41.4.1 src/sys/compat/linux32/arch/amd64/linux32_syscall.h:1.41.4.2
--- src/sys/compat/linux32/arch/amd64/linux32_syscall.h:1.41.4.1	Thu Nov 20 16:51:42 2008
+++ src/sys/compat/linux32/arch/amd64/linux32_syscall.h	Wed Mar 18 17:21:22 2015
@@ -1,10 +1,10 @@
-/* $NetBSD: linux32_syscall.h,v 1.41.4.1 2008/11/20 16:51:42 snj Exp $ */
+/* $NetBSD: linux32_syscall.h,v 1.41.4.2 2015/03/18 17:21:22 snj Exp $ */
 
 /*
  * System call numbers.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.38.4.1 2008/11/20 03:03:05 snj Exp
+ * created from	NetBSD: syscalls.master,v 1.38.4.2 2015/03/18 17:20:09 snj Exp
  */
 
 #ifndef _LINUX32_SYS_SYSCALL_H_
@@ -262,6 +262,9 @@
 /* syscall: statfs ret: int args: netbsd32_charp linux32_statfsp */
 #define	LINUX32_SYS_statfs	99
 
+/* syscall: fstatfs ret: int args: int linux32_statfsp */
+#define	LINUX32_SYS_fstatfs	100
+
 /* syscall: socketcall ret: int args: int netbsd32_voidp */
 #define	LINUX32_SYS_socketcall	102
 
@@ -271,6 +274,15 @@
 /* syscall: netbsd32_getitimer ret: int args: int netbsd32_itimervalp_t */
 #define	LINUX32_SYS_netbsd32_getitimer	105
 
+/* syscall: stat ret: int args: netbsd32_charp linux32_statp */
+#define	LINUX32_SYS_stat	106
+
+/* syscall: lstat ret: int args: netbsd32_charp linux32_statp */
+#define	LINUX32_SYS_lstat	107
+
+/* syscall: fstat ret: int args: int linux32_statp */
+#define	LINUX32_SYS_fstat	108
+
 /* syscall: olduname ret: int args: linux32_oldutsnamep_t */
 #define	LINUX32_SYS_olduname	109
 
Index: src/sys/compat/linux32/arch/amd64/linux32_syscallargs.h
diff -u src/sys/compat/linux32/arch/amd64/linux32_syscallargs.h:1.41.4.1 src/sys/compat/linux32/arch/amd64/linux32_syscallargs.h:1.41.4.2
--- src/sys/compat/linux32/arch/amd64/linux32_syscallargs.h:1.41.4.1	Thu Nov 20 16:51:42 2008
+++ src/sys/compat/linux32/arch/amd64/linux32_syscallargs.h	Wed Mar 18 17:21:22 2015
@@ -1,10 +1,10 @@
-/* $NetBSD: linux32_syscallargs.h,v 1.41.4.1 2008/11/20 16:51:42 snj Exp $ */
+/* $NetBSD: linux32_syscallargs.h,v 1.41.4.2 2015/03/18 17:21:22 snj Exp $ */
 
 /*
  * System call argument lists.
  *
  * DO NOT EDIT-- this file is automatically generated.
- * created from	NetBSD: syscalls.master,v 1.38.4.1 2008/11/20 03:03:05 snj Exp
+ * created from	NetBSD: syscalls.master,v 1.38.4.2 2015/03/18 17:20:09 snj Exp
  */
 
 #ifndef _LINUX32_SYS_SYSCALLARGS_H_
@@ -314,6 +314,12 @@ struct linux32_sys_statfs_args {
 };
 check_syscall_args(linux32_sys_statfs)
 
+struct linux32_sys_fstatfs_args {
+	syscallarg(int) fd;
+	syscallarg(linux32_statfsp) sp;
+};
+check_syscall_args(linux32_sys_fstatfs)
+
 struct linux32_sys_socketcall_args {
 	syscallarg(int) what;
 	syscallarg(netbsd32_voidp) args;
@@ -324,6 +330,24 @@ struct netbsd32_setitimer_args;
 
 struct netbsd32_getitimer_args;
 
+struct linux32_sys_stat_args {
+	syscallarg(netbsd32_charp) path;
+	syscallarg(linux32_statp) sp;
+};
+check_syscall_args(linux32_sys_stat)
+
+struct linux32_sys_lstat_args {
+	syscallarg(netbsd32_charp) path;
+	syscallarg(linux32_statp) sp;
+};
+check_syscall_args(linux32_sys_lstat)
+
+struct linux32_sys_fstat_args {
+	syscallarg(int) fd;
+	syscallarg(linux32_statp) sp;
+};
+check_syscall_args(linux32_sys_fstat)
+
 struct linux32_sys_olduname_args {
 	syscallarg(linux32_oldutsnamep_t) up;
 };
@@ -836,12 +860,20 @@ int	netbsd32_setpriority(struct lwp *, c
 
 int	linux32_sys_statfs(struct lwp *, const struct linux32_sys_statfs_args *, register_t *);
 
+int	linux32_sys_fstatfs(struct lwp *, const struct linux32_sys_fstatfs_args *, register_t *);
+
 int	linux32_sys_socketcall(struct lwp *, const struct linux32_sys_socketcall_args *, register_t *);
 
 int	netbsd32_setitimer(struct lwp *, const struct netbsd32_setitimer_args *, register_t *);
 
 int	netbsd32_getitimer(struct lwp *, const struct netbsd32_getitimer_args *, register_t *);
 
+int	linux32_sys_stat(struct lwp *, const struct linux32_sys_stat_args *, register_t *);
+
+int	linux32_sys_lstat(struct lwp *, const struct linux32_sys_lstat_args *, register_t *);
+
+int	linux32_sys_fstat(struct lwp *, const struct linux32_sys_fstat_args *, register_t *);
+
 int	

CVS commit: [netbsd-5] src/sys/compat/linux32

2015-03-18 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Mar 18 17:20:09 UTC 2015

Modified Files:
src/sys/compat/linux32/arch/amd64 [netbsd-5]: syscalls.master
src/sys/compat/linux32/common [netbsd-5]: linux32_misc.c linux32_stat.c

Log Message:
Pull up following revision(s) (requested by joerg in ticket #1149):
sys/compat/linux32/arch/amd64/syscalls.master: revisions 1.52, 1.53 via 
patch
sys/compat/linux32/common/linux32_misc.c: revision 1.17 via patch
sys/compat/linux32/common/linux32_stat.c: revision 1.14-1.16 via patch
Fix inverted lst_ino/__lst_ino assignment in linux32_from_stat().
--
Cleanup (no functional changes).
Kill some unneeded variables and return stattement.
Rename linux32_from_stat() to better bsd_to_linux32_stat64().
Fix some types.
Add stat/lstat/fstat syscalls.
--
Add fstatfs syscall.


To generate a diff of this commit:
cvs rdiff -u -r1.38.4.1 -r1.38.4.2 \
src/sys/compat/linux32/arch/amd64/syscalls.master
cvs rdiff -u -r1.12 -r1.12.6.1 src/sys/compat/linux32/common/linux32_misc.c
cvs rdiff -u -r1.11 -r1.11.14.1 src/sys/compat/linux32/common/linux32_stat.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/linux32/arch/amd64/syscalls.master
diff -u src/sys/compat/linux32/arch/amd64/syscalls.master:1.38.4.1 src/sys/compat/linux32/arch/amd64/syscalls.master:1.38.4.2
--- src/sys/compat/linux32/arch/amd64/syscalls.master:1.38.4.1	Thu Nov 20 03:03:05 2008
+++ src/sys/compat/linux32/arch/amd64/syscalls.master	Wed Mar 18 17:20:09 2015
@@ -1,4 +1,4 @@
-	$NetBSD: syscalls.master,v 1.38.4.1 2008/11/20 03:03:05 snj Exp $
+	$NetBSD: syscalls.master,v 1.38.4.2 2015/03/18 17:20:09 snj Exp $
 
 ; NetBSD i386 COMPAT_LINUX32 system call name/number master file.
 ; (See syscalls.conf to see what it is processed into.)
@@ -199,7 +199,7 @@
 98	UNIMPL	profil
 99	STD	{ int linux32_sys_statfs(netbsd32_charp path, \
 		linux32_statfsp sp); }
-100	UNIMPL	fstatfs
+100	STD	{ int linux32_sys_fstatfs(int fd, linux32_statfsp sp); }
 101	UNIMPL	ioperm
 102	STD	{ int linux32_sys_socketcall(int what, netbsd32_voidp args); }
 103	UNIMPL	syslog
@@ -207,9 +207,11 @@
 		netbsd32_itimervalp_t itv, netbsd32_itimervalp_t oitv); }
 105	NOARGS	{ int netbsd32_getitimer(int which, \
 		netbsd32_itimervalp_t itv); }
-106	UNIMPL	stat
-107	UNIMPL	lstat
-108	UNIMPL	fstat
+106	STD	{ int linux32_sys_stat(netbsd32_charp path, \
+		linux32_statp sp); }
+107	STD	{ int linux32_sys_lstat(netbsd32_charp path, \
+		linux32_statp sp); }
+108	STD	{ int linux32_sys_fstat(int fd, linux32_statp sp); }
 109	STD	{ int linux32_sys_olduname(linux32_oldutsnamep_t up); }
 110	UNIMPL	iopl
 111	UNIMPL	vhangup

Index: src/sys/compat/linux32/common/linux32_misc.c
diff -u src/sys/compat/linux32/common/linux32_misc.c:1.12 src/sys/compat/linux32/common/linux32_misc.c:1.12.6.1
--- src/sys/compat/linux32/common/linux32_misc.c:1.12	Wed Jun 18 22:58:21 2008
+++ src/sys/compat/linux32/common/linux32_misc.c	Wed Mar 18 17:20:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_misc.c,v 1.12 2008/06/18 22:58:21 njoly Exp $	*/
+/*	$NetBSD: linux32_misc.c,v 1.12.6.1 2015/03/18 17:20:09 snj Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux32_misc.c,v 1.12 2008/06/18 22:58:21 njoly Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux32_misc.c,v 1.12.6.1 2015/03/18 17:20:09 snj Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_ptrace.h
@@ -90,6 +90,28 @@ linux32_sys_statfs(struct lwp *l, const 
 	return error;
 }
 
+int
+linux32_sys_fstatfs(struct lwp *l, const struct linux32_sys_fstatfs_args *uap, register_t *retval)
+{
+	/* {
+		syscallarg(int) fd;
+		syscallarg(linux32_statfsp) sp;
+	} */
+	struct statvfs *sb;
+	struct linux_statfs ltmp;
+	int error;
+
+	sb = STATVFSBUF_GET();
+	error = do_sys_fstatvfs(l, SCARG(uap, fd), ST_WAIT, sb);
+	if (error == 0) {
+		bsd_to_linux_statfs(sb, ltmp);
+		error = copyout(ltmp, SCARG_P32(uap, sp), sizeof ltmp);
+	}
+	STATVFSBUF_PUT(sb);
+
+	return error;
+}
+
 extern const int linux_ptrace_request_map[];
 
 int

Index: src/sys/compat/linux32/common/linux32_stat.c
diff -u src/sys/compat/linux32/common/linux32_stat.c:1.11 src/sys/compat/linux32/common/linux32_stat.c:1.11.14.1
--- src/sys/compat/linux32/common/linux32_stat.c:1.11	Fri Mar 21 21:54:58 2008
+++ src/sys/compat/linux32/common/linux32_stat.c	Wed Mar 18 17:20:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_stat.c,v 1.11 2008/03/21 21:54:58 ad Exp $ */
+/*	$NetBSD: linux32_stat.c,v 1.11.14.1 2015/03/18 17:20:09 snj Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: linux32_stat.c,v 1.11 2008/03/21 21:54:58 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux32_stat.c,v 1.11.14.1 2015/03/18 17:20:09 snj Exp $);
 
 #include sys/types.h
 

CVS commit: [netbsd-5] src/sys/compat/freebsd

2014-10-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Oct 27 12:37:58 UTC 2014

Modified Files:
src/sys/compat/freebsd [netbsd-5]: freebsd_sysctl.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1926):
sys/compat/freebsd/freebsd_sysctl.c: revision 1.17
I'm not sure reading from an unsanitized userland pointer is a good idea.
Some users might be tempted to give 0x01, in which case the kernel will
crash.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.10.1 src/sys/compat/freebsd/freebsd_sysctl.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/freebsd/freebsd_sysctl.c
diff -u src/sys/compat/freebsd/freebsd_sysctl.c:1.14 src/sys/compat/freebsd/freebsd_sysctl.c:1.14.10.1
--- src/sys/compat/freebsd/freebsd_sysctl.c:1.14	Mon Apr 28 20:23:41 2008
+++ src/sys/compat/freebsd/freebsd_sysctl.c	Mon Oct 27 12:37:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: freebsd_sysctl.c,v 1.14 2008/04/28 20:23:41 martin Exp $	*/
+/*	$NetBSD: freebsd_sysctl.c,v 1.14.10.1 2014/10/27 12:37:57 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: freebsd_sysctl.c,v 1.14 2008/04/28 20:23:41 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: freebsd_sysctl.c,v 1.14.10.1 2014/10/27 12:37:57 msaitoh Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -84,7 +84,7 @@ freebsd_sys_sysctl(struct lwp *l, const 
 	} */
 	int error;
 	int name[CTL_MAXNAME];
-	size_t newlen, *oldlenp;
+	size_t newlen, *oldlenp, oldlen;
 	u_int namelen;
 	void *new, *old;
 
@@ -135,9 +135,14 @@ freebsd_sys_sysctl(struct lwp *l, const 
 
 		old = SCARG(uap, old);
 		oldlenp = SCARG(uap, oldlenp);
-		if (old == NULL || oldlenp == NULL || *oldlenp  sizeof(int))
+		if (old == NULL || oldlenp == NULL)
 			return(EINVAL);
 
+		if ((error = copyin(oldlenp, oldlen, sizeof(oldlen
+			return (error);
+		if (oldlen  sizeof(int))
+			return (EINVAL);
+
 		if ((locnew =
 		 (char *) malloc(newlen + 1, M_TEMP, M_WAITOK)) == NULL)
 			return(ENOMEM);
@@ -157,11 +162,11 @@ freebsd_sys_sysctl(struct lwp *l, const 
 
 		oidlen *= sizeof(int);
 		error = copyout(oid, SCARG(uap, old),
-MIN(oidlen, *SCARG(uap, oldlenp)));
+MIN(oidlen, oldlen));
 		if (error)
 			return(error);
 		ktrmibio(-1, UIO_READ, SCARG(uap, old),
-		MIN(oidlen, *SCARG(uap, oldlenp)),  0);
+		MIN(oidlen, oldlen),  0);
 
 		error = copyout(oidlen, SCARG(uap, oldlenp), sizeof(u_int));
 



CVS commit: [netbsd-5] src/sys/compat

2014-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Aug  8 06:52:24 UTC 2014

Modified Files:
src/sys/compat/linux/common [netbsd-5]: linux_socketcall.c
src/sys/compat/linux32/common [netbsd-5]: linux32_socketcall.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1916):
sys/compat/linux32/common/linux32_socketcall.c: revision 1.9
sys/compat/linux/common/linux_socketcall.c: revision 1.44
If SCARG(uap, what) = 0, copyin() will copy (size_t)-1 bytes, and it's not
a good idea; but not proven harmful.
With the help of njoly@


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.6.1 src/sys/compat/linux/common/linux_socketcall.c
cvs rdiff -u -r1.6 -r1.6.20.1 \
src/sys/compat/linux32/common/linux32_socketcall.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/linux/common/linux_socketcall.c
diff -u src/sys/compat/linux/common/linux_socketcall.c:1.39 src/sys/compat/linux/common/linux_socketcall.c:1.39.6.1
--- src/sys/compat/linux/common/linux_socketcall.c:1.39	Thu Jul  3 14:07:09 2008
+++ src/sys/compat/linux/common/linux_socketcall.c	Fri Aug  8 06:52:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socketcall.c,v 1.39 2008/07/03 14:07:09 njoly Exp $	*/
+/*	$NetBSD: linux_socketcall.c,v 1.39.6.1 2014/08/08 06:52:24 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.39 2008/07/03 14:07:09 njoly Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.39.6.1 2014/08/08 06:52:24 msaitoh Exp $);
 
 #include sys/param.h
 #include sys/kernel.h
@@ -123,7 +123,7 @@ linux_sys_socketcall(struct lwp *l, cons
 	struct linux_socketcall_dummy_args lda;
 	int error;
 
-	if (SCARG(uap, what)  0 || SCARG(uap, what)  LINUX_MAX_SOCKETCALL)
+	if (SCARG(uap, what) = 0 || SCARG(uap, what)  LINUX_MAX_SOCKETCALL)
 		return ENOSYS;
 
 	if ((error = copyin(SCARG(uap, args), lda,

Index: src/sys/compat/linux32/common/linux32_socketcall.c
diff -u src/sys/compat/linux32/common/linux32_socketcall.c:1.6 src/sys/compat/linux32/common/linux32_socketcall.c:1.6.20.1
--- src/sys/compat/linux32/common/linux32_socketcall.c:1.6	Thu Dec 20 23:02:58 2007
+++ src/sys/compat/linux32/common/linux32_socketcall.c	Fri Aug  8 06:52:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socketcall.c,v 1.6 2007/12/20 23:02:58 dsl Exp $ */
+/*	$NetBSD: linux32_socketcall.c,v 1.6.20.1 2014/08/08 06:52:24 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -31,7 +31,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux32_socketcall.c,v 1.6 2007/12/20 23:02:58 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux32_socketcall.c,v 1.6.20.1 2014/08/08 06:52:24 msaitoh Exp $);
 
 #include opt_ktrace.h
 #include sys/types.h
@@ -95,7 +95,7 @@ linux32_sys_socketcall(struct lwp *l, co
 	union linux32_socketcall_args ua;
 	int error;
 
-	if (SCARG(uap, what)  0 || SCARG(uap, what)  LINUX32_MAX_SOCKETCALL)
+	if (SCARG(uap, what) = 0 || SCARG(uap, what)  LINUX32_MAX_SOCKETCALL)
 		return ENOSYS;
 
 	if ((error = copyin(SCARG_P32(uap, args), ua,



CVS commit: [netbsd-5] src/sys/compat/freebsd

2014-06-30 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 30 10:53:59 UTC 2014

Modified Files:
src/sys/compat/freebsd [netbsd-5]: freebsd_sched.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1909):
sys/compat/freebsd/freebsd_sched.c  1.20-1.21

Avoid NULL dereference and fix sched param conversion (at least make it
do something). Pointed out by Maxime Villard.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.10.1 src/sys/compat/freebsd/freebsd_sched.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/freebsd/freebsd_sched.c
diff -u src/sys/compat/freebsd/freebsd_sched.c:1.19 src/sys/compat/freebsd/freebsd_sched.c:1.19.10.1
--- src/sys/compat/freebsd/freebsd_sched.c:1.19	Mon Apr 28 20:23:41 2008
+++ src/sys/compat/freebsd/freebsd_sched.c	Mon Jun 30 10:53:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: freebsd_sched.c,v 1.19 2008/04/28 20:23:41 martin Exp $	*/
+/*	$NetBSD: freebsd_sched.c,v 1.19.10.1 2014/06/30 10:53:59 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: freebsd_sched.c,v 1.19 2008/04/28 20:23:41 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: freebsd_sched.c,v 1.19.10.1 2014/06/30 10:53:59 msaitoh Exp $);
 
 #include sys/param.h
 #include sys/mount.h
@@ -62,72 +62,72 @@ freebsd_sys_yield(struct lwp *l, const v
  */
 static int
 sched_freebsd2native(int freebsd_policy,
-struct freebsd_sched_param *freebsd_params, int *native_policy,
+const struct freebsd_sched_param *freebsd_params, int *native_policy,
 struct sched_param *native_params)
 {
-	int error;
-
-	error = 0;
+	int p;
 
 	switch (freebsd_policy) {
 	case FREEBSD_SCHED_OTHER:
-		*native_policy = SCHED_OTHER;
+		p = SCHED_OTHER;
 		break;
 
 	case FREEBSD_SCHED_FIFO:
-		*native_policy = SCHED_FIFO;
+		p = SCHED_FIFO;
 		break;
 
 	case FREEBSD_SCHED_RR:
-		*native_policy = SCHED_RR;
+		p = SCHED_RR;
 		break;
 
 	default:
-		error = EINVAL;
-		break;
+		return EINVAL;
 	}
  
-	if (freebsd_params != NULL  native_params != NULL  !error) {
-		native_params = (struct sched_param *)freebsd_params;
+	if (native_policy != NULL)
+		*native_policy = p;
+
+	if (freebsd_params != NULL  native_params != NULL) {
+		/* XXX: Needs adjustment to do a proper conversion. */
+		native_params-sched_priority = freebsd_params-sched_priority;
 	}
-
-	return (error);
+	return 0;
 }
 
 /*
- * XXX: Needs adjustment to do a proper conversion.
  */
 static int
-sched_native2freebsd(int native_policy, struct sched_param *native_params,
+sched_native2freebsd(int native_policy, const struct sched_param *native_params,
 int *freebsd_policy, struct freebsd_sched_param *freebsd_params)
 {
-	int error;
-
-	error = 0;
+	int p;
 
 	switch (native_policy) {
 	case SCHED_OTHER:
-		*freebsd_policy = FREEBSD_SCHED_OTHER;
+		p = FREEBSD_SCHED_OTHER;
 		break;
 
 	case SCHED_FIFO:
-		*freebsd_policy = FREEBSD_SCHED_FIFO;
+		p = FREEBSD_SCHED_FIFO;
 		break;
 
 	case SCHED_RR:
-		*freebsd_policy = FREEBSD_SCHED_RR;
+		p = FREEBSD_SCHED_RR;
 		break;
 
 	default:
-		error = EINVAL;
-		break;
+		return EINVAL;
 	}
  
-	if (native_params != NULL  freebsd_params != NULL  !error) {
-		freebsd_params = (struct freebsd_sched_param *)native_params;
+	if (freebsd_policy != NULL)
+		*freebsd_policy = p;
+
+	if (native_params != NULL  freebsd_params != NULL) {
+		/* XXX: Needs adjustment to do a proper conversion. */
+		freebsd_params-sched_priority = native_params-sched_priority;
 	}
-
-	return (error);
+
+	return 0;
 }
 
 int
@@ -199,7 +199,7 @@ freebsd_sys_sched_getparam(struct lwp *l
 		goto out;
 
  out:
-	return (error);
+	return error;
 }
 
 int



CVS commit: [netbsd-5] src/sys/compat/linux/common

2014-05-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 14 05:14:47 UTC 2014

Modified Files:
src/sys/compat/linux/common [netbsd-5]: linux_exec_elf32.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1902):
src/sys/compat/linux/common/linux_exec_elf32.c  1.91 via patch

A specially-crafted binary could easily control a kernel array index.
Add some checks to ensure that nothing will be read outside the allocated
area. Rewrite the code so that we don't need to allocate the whole section.

Spotted by several developers, patch from chs@/enami@


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.81.10.1 \
src/sys/compat/linux/common/linux_exec_elf32.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/linux/common/linux_exec_elf32.c
diff -u src/sys/compat/linux/common/linux_exec_elf32.c:1.81 src/sys/compat/linux/common/linux_exec_elf32.c:1.81.10.1
--- src/sys/compat/linux/common/linux_exec_elf32.c:1.81	Mon Apr 28 20:23:43 2008
+++ src/sys/compat/linux/common/linux_exec_elf32.c	Wed May 14 05:14:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_exec_elf32.c,v 1.81 2008/04/28 20:23:43 martin Exp $	*/
+/*	$NetBSD: linux_exec_elf32.c,v 1.81.10.1 2014/05/14 05:14:47 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_exec_elf32.c,v 1.81 2008/04/28 20:23:43 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_exec_elf32.c,v 1.81.10.1 2014/05/14 05:14:47 msaitoh Exp $);
 
 #ifndef ELFSIZE
 /* XXX should die */
@@ -89,50 +89,43 @@ ELFNAME2(linux,atexit_signature)(l, epp,
 	struct exec_package *epp;
 	Elf_Ehdr *eh;
 {
+	Elf_Shdr *sh;
 	size_t shsize;
-	int strndx;
+	u_int shstrndx;
 	size_t i;
 	static const char signature[] = __libc_atexit;
-	char *strtable = NULL;
-	Elf_Shdr *sh;
-
+	const size_t sigsz = sizeof(signature);
+	char tbuf[sizeof(signature)];
 	int error;
 
-	/*
-	 * load the section header table
-	 */
+	/* Load the section header table. */
 	shsize = eh-e_shnum * sizeof(Elf_Shdr);
 	sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
 	error = exec_read_from(l, epp-ep_vp, eh-e_shoff, sh, shsize);
 	if (error)
 		goto out;
 
-	/*
-	 * Now let's find the string table. If it does not exists, give up.
-	 */
-	strndx = (int)(eh-e_shstrndx);
-	if (strndx == SHN_UNDEF) {
+	/* Now let's find the string table. If it does not exist, give up. */
+	shstrndx = eh-e_shstrndx;
+	if (shstrndx == SHN_UNDEF || shstrndx = eh-e_shnum) {
 		error = ENOEXEC;
 		goto out;
 	}
 
-	/*
-	 * strndx is the index in section header table of the string table
-	 * section get the whole string table in strtable, and then we get access to the names
-	 * s-sh_name is the offset of the section name in strtable.
-	 */
-	strtable = malloc(sh[strndx].sh_size, M_TEMP, M_WAITOK);
-	error = exec_read_from(l, epp-ep_vp, sh[strndx].sh_offset, strtable,
-	sh[strndx].sh_size);
-	if (error)
-		goto out;
-
+	/* Check if any section has the name we're looking for. */
+	const off_t stroff = sh[shstrndx].sh_offset;
 	for (i = 0; i  eh-e_shnum; i++) {
 		Elf_Shdr *s = sh[i];
-		if (!memcmp((void*)((strtable[s-sh_name])), signature,
-sizeof(signature))) {
-			DPRINTF((linux_atexit_sig=%s\n,
-			(strtable[s-sh_name])));
+
+		if (s-sh_name + sigsz  sh[shstrndx].sh_size)
+			continue;
+
+		error = exec_read_from(l, epp-ep_vp, stroff + s-sh_name, tbuf,
+		sigsz);
+		if (error)
+			goto out;
+		if (!memcmp(tbuf, signature, sigsz)) {
+			DPRINTF((linux_atexit_sig=%s\n, tbuf));
 			error = 0;
 			goto out;
 		}
@@ -141,8 +134,6 @@ ELFNAME2(linux,atexit_signature)(l, epp,
 
 out:
 	free(sh, M_TEMP);
-	if (strtable)
-		free(strtable, M_TEMP);
 	return (error);
 }
 #endif
@@ -216,59 +207,48 @@ out:
 
 #ifdef LINUX_DEBUGLINK_SIGNATURE
 /*
- * Look for a .gnu_debuglink, specific to x86_64 interpeter
+ * Look for a .gnu_debuglink, specific to x86_64 interpreter
  */
 int
-ELFNAME2(linux,debuglink_signature)(l, epp, eh)
-	struct lwp *l;
-	struct exec_package *epp;
-	Elf_Ehdr *eh;
+ELFNAME2(linux,debuglink_signature)(struct lwp *l, struct exec_package *epp, Elf_Ehdr *eh)
 {
+	Elf_Shdr *sh;
 	size_t shsize;
-	int strndx;
+	u_int shstrndx;
 	size_t i;
 	static const char signature[] = .gnu_debuglink;
-	char *strtable = NULL;
-	Elf_Shdr *sh;
-
+	const size_t sigsz = sizeof(signature);
+	char tbuf[sizeof(signature)];
 	int error;
 
-	/*
-	 * load the section header table
-	 */
+	/* Load the section header table. */
 	shsize = eh-e_shnum * sizeof(Elf_Shdr);
 	sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
 	error = exec_read_from(l, epp-ep_vp, eh-e_shoff, sh, shsize);
 	if (error)
 		goto out;
 
-	/*
-	 * Now let's find the string table. If it does not exists, give up.
-	 */
-	strndx = (int)(eh-e_shstrndx);
-	if (strndx == SHN_UNDEF) {
+	/* Now let's find the string table. If it 

CVS commit: [netbsd-5] src/sys/compat/common

2013-12-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Dec 17 21:00:02 UTC 2013

Modified Files:
src/sys/compat/common [netbsd-5]: compat_util.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1893):
sys/compat/common/compat_util.c: revision 1.45
Free pathbuf in an error path.
From Maxime Villard.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.10.1 src/sys/compat/common/compat_util.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/common/compat_util.c
diff -u src/sys/compat/common/compat_util.c:1.41 src/sys/compat/common/compat_util.c:1.41.10.1
--- src/sys/compat/common/compat_util.c:1.41	Mon Apr 28 20:23:41 2008
+++ src/sys/compat/common/compat_util.c	Tue Dec 17 21:00:01 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: compat_util.c,v 1.41 2008/04/28 20:23:41 martin Exp $	*/
+/* 	$NetBSD: compat_util.c,v 1.41.10.1 2013/12/17 21:00:01 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: compat_util.c,v 1.41 2008/04/28 20:23:41 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: compat_util.c,v 1.41.10.1 2013/12/17 21:00:01 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -106,6 +106,7 @@ emul_find_interp(struct lwp *l, struct e
 	error = namei(nd);
 	if (error != 0) {
 		epp-ep_interp = NULL;
+		pathbuf_destroy(pb);
 		return error;
 	}
 



CVS commit: [netbsd-5] src/sys/compat/common

2013-12-17 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Dec 18 04:05:19 UTC 2013

Modified Files:
src/sys/compat/common [netbsd-5]: compat_util.c

Log Message:
Revert ticket #1893 - netbsd-5 does not have pathbuf_destroy()


To generate a diff of this commit:
cvs rdiff -u -r1.41.10.1 -r1.41.10.2 src/sys/compat/common/compat_util.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/common/compat_util.c
diff -u src/sys/compat/common/compat_util.c:1.41.10.1 src/sys/compat/common/compat_util.c:1.41.10.2
--- src/sys/compat/common/compat_util.c:1.41.10.1	Tue Dec 17 21:00:01 2013
+++ src/sys/compat/common/compat_util.c	Wed Dec 18 04:05:19 2013
@@ -1,4 +1,4 @@
-/* 	$NetBSD: compat_util.c,v 1.41.10.1 2013/12/17 21:00:01 bouyer Exp $	*/
+/* 	$NetBSD: compat_util.c,v 1.41.10.2 2013/12/18 04:05:19 riz Exp $	*/
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: compat_util.c,v 1.41.10.1 2013/12/17 21:00:01 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: compat_util.c,v 1.41.10.2 2013/12/18 04:05:19 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -106,7 +106,6 @@ emul_find_interp(struct lwp *l, struct e
 	error = namei(nd);
 	if (error != 0) {
 		epp-ep_interp = NULL;
-		pathbuf_destroy(pb);
 		return error;
 	}
 



CVS commit: [netbsd-5] src/sys/compat/netbsd32

2013-01-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 13 16:22:17 UTC 2013

Modified Files:
src/sys/compat/netbsd32 [netbsd-5]: netbsd32_fs.c

Log Message:
Pull up following revision(s) (requested by matt in ticket #1829):
sys/compat/netbsd32/netbsd32_fs.c: revision 1.64
Fix inverted error check.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.6.1 src/sys/compat/netbsd32/netbsd32_fs.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_fs.c
diff -u src/sys/compat/netbsd32/netbsd32_fs.c:1.55 src/sys/compat/netbsd32/netbsd32_fs.c:1.55.6.1
--- src/sys/compat/netbsd32/netbsd32_fs.c:1.55	Tue Jun 24 11:18:15 2008
+++ src/sys/compat/netbsd32/netbsd32_fs.c	Sun Jan 13 16:22:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_fs.c,v 1.55 2008/06/24 11:18:15 ad Exp $	*/
+/*	$NetBSD: netbsd32_fs.c,v 1.55.6.1 2013/01/13 16:22:17 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: netbsd32_fs.c,v 1.55 2008/06/24 11:18:15 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: netbsd32_fs.c,v 1.55.6.1 2013/01/13 16:22:17 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -593,7 +593,7 @@ netbsd32___fhstat40(struct lwp *l, const
 	int error;
 
 	error = do_fhstat(l, SCARG_P32(uap, fhp), SCARG(uap, fh_size), sb);
-	if (error != 0) {
+	if (error == 0) {
 		netbsd32_from___stat30(sb, sb32);
 		error = copyout(sb32, SCARG_P32(uap, sb), sizeof(sb));
 	}



CVS commit: [netbsd-5] src/sys/compat

2010-03-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Mar 17 02:59:53 UTC 2010

Modified Files:
src/sys/compat/common [netbsd-5]: vfs_syscalls_30.c
src/sys/compat/ibcs2 [netbsd-5]: ibcs2_misc.c
src/sys/compat/irix [netbsd-5]: irix_dirent.c
src/sys/compat/linux/common [netbsd-5]: linux_file64.c linux_misc.c
src/sys/compat/linux32/common [netbsd-5]: linux32_dirent.c
src/sys/compat/sunos [netbsd-5]: sunos_misc.c
src/sys/compat/sunos32 [netbsd-5]: sunos32_misc.c
src/sys/compat/svr4 [netbsd-5]: svr4_misc.c
src/sys/compat/svr4_32 [netbsd-5]: svr4_32_misc.c

Log Message:
Pull up following revision(s) (requested by he in ticket #1323):
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
When implementing read directory, when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.6.1 src/sys/compat/common/vfs_syscalls_30.c
cvs rdiff -u -r1.104 -r1.104.6.1 src/sys/compat/ibcs2/ibcs2_misc.c
cvs rdiff -u -r1.23 -r1.23.10.1 src/sys/compat/irix/irix_dirent.c
cvs rdiff -u -r1.48 -r1.48.6.1 src/sys/compat/linux/common/linux_file64.c
cvs rdiff -u -r1.201 -r1.201.6.1 src/sys/compat/linux/common/linux_misc.c
cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/compat/linux32/common/linux32_dirent.c
cvs rdiff -u -r1.161 -r1.161.4.1 src/sys/compat/sunos/sunos_misc.c
cvs rdiff -u -r1.62 -r1.62.4.1 src/sys/compat/sunos32/sunos32_misc.c
cvs rdiff -u -r1.144 -r1.144.6.1 src/sys/compat/svr4/svr4_misc.c
cvs rdiff -u -r1.63 -r1.63.6.1 src/sys/compat/svr4_32/svr4_32_misc.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/common/vfs_syscalls_30.c
diff -u src/sys/compat/common/vfs_syscalls_30.c:1.28 src/sys/compat/common/vfs_syscalls_30.c:1.28.6.1
--- src/sys/compat/common/vfs_syscalls_30.c:1.28	Tue Jun 24 11:18:15 2008
+++ src/sys/compat/common/vfs_syscalls_30.c	Wed Mar 17 02:59:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_30.c,v 1.28 2008/06/24 11:18:15 ad Exp $	*/
+/*	$NetBSD: vfs_syscalls_30.c,v 1.28.6.1 2010/03/17 02:59:51 snj Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vfs_syscalls_30.c,v 1.28 2008/06/24 11:18:15 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: vfs_syscalls_30.c,v 1.28.6.1 2010/03/17 02:59:51 snj Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -310,8 +310,12 @@
 	}
 
 	/* if we squished out the whole block, try again */
-	if (outp == SCARG(uap, buf))
+	if (outp == SCARG(uap, buf)) {
+		if (cookiebuf)
+			free(cookiebuf, M_TEMP);
+		cookiebuf = NULL;
 		goto again;
+	}
 	fp-f_offset = off;	/* update the vnode offset */
 
 eof:

Index: src/sys/compat/ibcs2/ibcs2_misc.c
diff -u src/sys/compat/ibcs2/ibcs2_misc.c:1.104 src/sys/compat/ibcs2/ibcs2_misc.c:1.104.6.1
--- src/sys/compat/ibcs2/ibcs2_misc.c:1.104	Tue Jun 24 11:18:15 2008
+++ src/sys/compat/ibcs2/ibcs2_misc.c	Wed Mar 17 02:59:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibcs2_misc.c,v 1.104 2008/06/24 11:18:15 ad Exp $	*/
+/*	$NetBSD: ibcs2_misc.c,v 1.104.6.1 2010/03/17 02:59:51 snj Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -95,7 +95,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ibcs2_misc.c,v 1.104 2008/06/24 11:18:15 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: ibcs2_misc.c,v 1.104.6.1 2010/03/17 02:59:51 snj Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -473,8 +473,12 @@
 	}
 
 	/* if we squished out the whole block, try again */
-	if (outp == SCARG(uap, buf))
+	if (outp == SCARG(uap, buf)) {
+		if (cookiebuf)
+			free(cookiebuf, M_TEMP);
+		cookiebuf = NULL;
 		goto again;
+	}
 	fp-f_offset = off;	/* update the vnode offset */
 
 eof:
@@ -603,8 +607,12 @@
 		resid -= ibcs2_reclen;
 	}
 	/* if we squished out the whole block, try again */
-	if (outp == SCARG(uap, buf))
+	if (outp == 

CVS commit: [netbsd-5] src/sys/compat

2009-11-28 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Nov 28 15:45:02 UTC 2009

Modified Files:
src/sys/compat/linux/common [netbsd-5]: linux_socket.c linux_sockio.h
src/sys/compat/linux32/common [netbsd-5]: linux32_socket.c
linux32_sockio.h

Log Message:
Pull up following revision(s) (requested by joerg in ticket #1147):
sys/compat/linux32/common/linux32_socket.c: revision 1.11, 1.12
sys/compat/linux/common/linux_socket.c: revision 1.105, 1.106
sys/compat/linux/common/linux_sockio.h: revision 1.17
sys/compat/linux32/common/linux32_sockio.h: revision 1.3
Provide SIOCGIFNAME.
Return the result of copyout. Reminded by Niolas Joly.


To generate a diff of this commit:
cvs rdiff -u -r1.98.4.1 -r1.98.4.2 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.16 -r1.16.6.1 src/sys/compat/linux/common/linux_sockio.h
cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/compat/linux32/common/linux32_socket.c
cvs rdiff -u -r1.2 -r1.2.6.1 src/sys/compat/linux32/common/linux32_sockio.h

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/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.98.4.1 src/sys/compat/linux/common/linux_socket.c:1.98.4.2
--- src/sys/compat/linux/common/linux_socket.c:1.98.4.1	Wed Jun 17 20:15:53 2009
+++ src/sys/compat/linux/common/linux_socket.c	Sat Nov 28 15:45:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.98.4.1 2009/06/17 20:15:53 bouyer Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.98.4.2 2009/11/28 15:45:02 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.98.4.1 2009/06/17 20:15:53 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.98.4.2 2009/11/28 15:45:02 bouyer Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_inet.h
@@ -116,6 +116,7 @@
 int linux_to_bsd_ip_sockopt(int);
 int linux_to_bsd_tcp_sockopt(int);
 int linux_to_bsd_udp_sockopt(int);
+int linux_getifname(struct lwp *, register_t *, void *);
 int linux_getifconf(struct lwp *, register_t *, void *);
 int linux_getifhwaddr(struct lwp *, register_t *, u_int, void *);
 static int linux_get_sa(struct lwp *, int, struct mbuf **,
@@ -969,6 +970,29 @@
 }
 
 int
+linux_getifname(struct lwp *l, register_t *retval, void *data)
+{
+	struct ifnet *ifp;
+	struct linux_ifreq ifr;
+	int error;
+
+	error = copyin(data, ifr, sizeof(ifr));
+	if (error)
+		return error;
+
+	if (ifr.ifr_ifru.ifru_ifindex = if_indexlim)
+		return ENODEV;
+	
+	ifp = ifindex2ifnet[ifr.ifr_ifru.ifru_ifindex];
+	if (ifp == NULL)
+		return ENODEV;
+
+	strncpy(ifr.ifr_name, ifp-if_xname, sizeof(ifr.ifr_name));
+
+	return copyout(ifr, data, sizeof(ifr));
+}
+
+int
 linux_getifconf(struct lwp *l, register_t *retval, void *data)
 {
 	struct linux_ifreq ifr, *ifrp;
@@ -1189,6 +1213,10 @@
 	retval[0] = 0;
 
 	switch (com) {
+	case LINUX_SIOCGIFNAME:
+		error = linux_getifname(l, retval, SCARG(uap, data));
+		dosys = 0;
+		break;
 	case LINUX_SIOCGIFCONF:
 		error = linux_getifconf(l, retval, SCARG(uap, data));
 		dosys = 0;

Index: src/sys/compat/linux/common/linux_sockio.h
diff -u src/sys/compat/linux/common/linux_sockio.h:1.16 src/sys/compat/linux/common/linux_sockio.h:1.16.6.1
--- src/sys/compat/linux/common/linux_sockio.h:1.16	Thu Jul  3 14:07:09 2008
+++ src/sys/compat/linux/common/linux_sockio.h	Sat Nov 28 15:45:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sockio.h,v 1.16 2008/07/03 14:07:09 njoly Exp $	*/
+/*	$NetBSD: linux_sockio.h,v 1.16.6.1 2009/11/28 15:45:02 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
 #ifndef _LINUX_SOCKIO_H
 #define _LINUX_SOCKIO_H
 
+#define	LINUX_SIOCGIFNAME	_LINUX_IO(0x89, 0x10)
 #define	LINUX_SIOCGIFCONF	_LINUX_IO(0x89, 0x12)
 #define	LINUX_SIOCGIFFLAGS	_LINUX_IO(0x89, 0x13)
 #define	LINUX_SIOCSIFFLAGS	_LINUX_IO(0x89, 0x14)
@@ -66,6 +67,7 @@
 		struct osockaddr ifru_addr;
 		struct osockaddr ifru_hwaddr;
 		struct linux_ifmap ifru_map;
+		int ifru_ifindex;
 	} ifr_ifru;
 #define ifr_name	ifr_ifrn.ifrn_name	/* interface name   */
 #define ifr_addr	ifr_ifru.ifru_addr	/* address  */

Index: src/sys/compat/linux32/common/linux32_socket.c
diff -u src/sys/compat/linux32/common/linux32_socket.c:1.9 src/sys/compat/linux32/common/linux32_socket.c:1.9.4.1
--- src/sys/compat/linux32/common/linux32_socket.c:1.9	Wed Jul 23 12:32:09 2008
+++ src/sys/compat/linux32/common/linux32_socket.c	Sat Nov 28 15:45:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socket.c,v 1.9 2008/07/23 12:32:09 njoly Exp $ */
+/*	$NetBSD: linux32_socket.c,v 1.9.4.1 2009/11/28 15:45:02 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: linux32_socket.c,v 1.9 2008/07/23 12:32:09 njoly 

CVS commit: [netbsd-5] src/sys/compat/linux/common

2009-06-19 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Jun 19 21:42:28 UTC 2009

Modified Files:
src/sys/compat/linux/common [netbsd-5]: linux_sched.c

Log Message:
Pull up following revision(s) (requested by njoly in ticket #822):
sys/compat/linux/common/linux_sched.c: revision 1.59
In linux_sys_sched_getaffinity(), do not leak memory on error.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.58.4.1 src/sys/compat/linux/common/linux_sched.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/linux/common/linux_sched.c
diff -u src/sys/compat/linux/common/linux_sched.c:1.58 src/sys/compat/linux/common/linux_sched.c:1.58.4.1
--- src/sys/compat/linux/common/linux_sched.c:1.58	Sat Oct 25 23:38:28 2008
+++ src/sys/compat/linux/common/linux_sched.c	Fri Jun 19 21:42:28 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_sched.c,v 1.58 2008/10/25 23:38:28 christos Exp $	*/
+/*	$NetBSD: linux_sched.c,v 1.58.4.1 2009/06/19 21:42:28 snj Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.58 2008/10/25 23:38:28 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.58.4.1 2009/06/19 21:42:28 snj Exp $);
 
 #include sys/param.h
 #include sys/mount.h
@@ -646,12 +646,11 @@
 	retp = (int *)data[SCARG(uap, len) - sizeof(ret)];
 	*retp = ret;
 
-	if ((error = copyout(data, SCARG(uap, mask), SCARG(uap, len))) != 0)
-		return error;
+	error = copyout(data, SCARG(uap, mask), SCARG(uap, len));
 
 	free(data, M_TEMP);
 
-	return 0;
+	return error;
 
 }
 



CVS commit: [netbsd-5] src/sys/compat/linux/common

2009-06-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Jun 17 20:15:54 UTC 2009

Modified Files:
src/sys/compat/linux/common [netbsd-5]: linux_socket.c

Log Message:
Pull up following revision(s) (requested by njoly in ticket #806):
sys/compat/linux/common/linux_socket.c: revision 1.100
In sendmsg(2), do copy the msghdr structure before trying to use it.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.98.4.1 src/sys/compat/linux/common/linux_socket.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/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.98 src/sys/compat/linux/common/linux_socket.c:1.98.4.1
--- src/sys/compat/linux/common/linux_socket.c:1.98	Wed Aug  6 15:01:23 2008
+++ src/sys/compat/linux/common/linux_socket.c	Wed Jun 17 20:15:53 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.98 2008/08/06 15:01:23 plunky Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.98.4.1 2009/06/17 20:15:53 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.98 2008/08/06 15:01:23 plunky Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.98.4.1 2009/06/17 20:15:53 bouyer Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_inet.h
@@ -411,6 +411,10 @@
 	u_int8_t	*control;
 	struct mbuf *ctl_mbuf = NULL;
 
+	error = copyin(SCARG(uap, msg), msg, sizeof(msg));
+	if (error)
+		return error;
+
 	msg.msg_flags = MSG_IOVUSRSPACE;
 
 	/*



CVS commit: [netbsd-5] src/sys/compat/darwin

2009-03-31 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Apr  1 00:27:20 UTC 2009

Modified Files:
src/sys/compat/darwin [netbsd-5]: darwin_exec.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #622):
sys/compat/darwin/darwin_exec.c: revision 1.58
buildfix: NEW_VMCMD(2 - NEW_VMCMD2(


To generate a diff of this commit:
cvs rdiff -u -r1.55.4.1 -r1.55.4.2 src/sys/compat/darwin/darwin_exec.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/darwin/darwin_exec.c
diff -u src/sys/compat/darwin/darwin_exec.c:1.55.4.1 src/sys/compat/darwin/darwin_exec.c:1.55.4.2
--- src/sys/compat/darwin/darwin_exec.c:1.55.4.1	Wed Apr  1 00:25:21 2009
+++ src/sys/compat/darwin/darwin_exec.c	Wed Apr  1 00:27:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: darwin_exec.c,v 1.55.4.1 2009/04/01 00:25:21 snj Exp $ */
+/*	$NetBSD: darwin_exec.c,v 1.55.4.2 2009/04/01 00:27:20 snj Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include opt_compat_darwin.h /* For COMPAT_DARWIN in mach_port.h */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: darwin_exec.c,v 1.55.4.1 2009/04/01 00:25:21 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: darwin_exec.c,v 1.55.4.2 2009/04/01 00:27:20 snj Exp $);
 
 #include opt_syscall_debug.h
 
@@ -430,7 +430,7 @@
 		noaccess_linear_min, NULL, 0, VM_PROT_NONE, VMCMD_STACK);
 	}
 	KASSERT(access_size  0);
-	NEW_VMCMD(2epp-ep_vmcmds, vmcmd_map_zero, access_size,
+	NEW_VMCMD2(epp-ep_vmcmds, vmcmd_map_zero, access_size,
 	access_linear_min, NULL, 0, VM_PROT_READ | VM_PROT_WRITE,
 	VMCMD_STACK);