Module Name: src Committed By: martin Date: Mon Dec 29 16:35:51 UTC 2014
Modified Files: src/sys/compat/common [netbsd-7]: vfs_syscalls_30.c src/sys/compat/linux/common [netbsd-7]: linux_uselib.c src/sys/ufs/chfs [netbsd-7]: chfs_vfsops.c Log Message: Pull up following revision(s) (requested by maxv in ticket #353): sys/ufs/chfs/chfs_vfsops.c: revision 1.12 sys/compat/common/vfs_syscalls_30.c: revision 1.35 sys/compat/linux/common/linux_uselib.c: revision 1.31 sys/compat/linux/common/linux_uselib.c: revision 1.32 Resource leak. Memory leaks. Reject non-regular files. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.33.34.1 src/sys/compat/common/vfs_syscalls_30.c cvs rdiff -u -r1.30 -r1.30.38.1 src/sys/compat/linux/common/linux_uselib.c cvs rdiff -u -r1.11 -r1.11.2.1 src/sys/ufs/chfs/chfs_vfsops.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.33 src/sys/compat/common/vfs_syscalls_30.c:1.33.34.1 --- src/sys/compat/common/vfs_syscalls_30.c:1.33 Fri Nov 19 06:44:35 2010 +++ src/sys/compat/common/vfs_syscalls_30.c Mon Dec 29 16:35:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls_30.c,v 1.33 2010/11/19 06:44:35 dholland Exp $ */ +/* $NetBSD: vfs_syscalls_30.c,v 1.33.34.1 2014/12/29 16:35:51 martin 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.33 2010/11/19 06:44:35 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.33.34.1 2014/12/29 16:35:51 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -356,9 +356,13 @@ compat_30_sys_getfh(struct lwp *l, const } NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, pb); error = namei(&nd); - if (error) + if (error) { + pathbuf_destroy(pb); return (error); + } vp = nd.ni_vp; + pathbuf_destroy(pb); + sz = sizeof(struct compat_30_fhandle); error = vfs_composefh(vp, (void *)&fh, &sz); vput(vp); Index: src/sys/compat/linux/common/linux_uselib.c diff -u src/sys/compat/linux/common/linux_uselib.c:1.30 src/sys/compat/linux/common/linux_uselib.c:1.30.38.1 --- src/sys/compat/linux/common/linux_uselib.c:1.30 Fri Aug 28 01:39:03 2009 +++ src/sys/compat/linux/common/linux_uselib.c Mon Dec 29 16:35:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $ */ +/* $NetBSD: linux_uselib.c,v 1.30.38.1 2014/12/29 16:35:51 martin Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_uselib.c,v 1.30.38.1 2014/12/29 16:35:51 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -100,20 +100,26 @@ linux_sys_uselib(struct lwp *l, const st if (error != 0) return error; + if (vp->v_type != VREG) { + error = EINVAL; + goto out; + } + if ((error = vn_rdwr(UIO_READ, vp, (void *) &hdr, LINUX_AOUT_HDR_SIZE, 0, UIO_SYSSPACE, IO_NODELOCKED, l->l_cred, &rem, NULL))) { - vrele(vp); - return error; + goto out; } if (rem != 0) { - vrele(vp); - return ENOEXEC; + error = ENOEXEC; + goto out; } - if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE) - return ENOEXEC; + if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE) { + error = ENOEXEC; + goto out; + } magic = LINUX_N_MAGIC(&hdr); taddr = hdr.a_entry & (~(PAGE_SIZE - 1)); @@ -123,7 +129,7 @@ linux_sys_uselib(struct lwp *l, const st error = vn_marktext(vp); if (error) - return (error); + goto out; vcset.evs_cnt = 0; vcset.evs_used = 0; @@ -150,7 +156,7 @@ linux_sys_uselib(struct lwp *l, const st kill_vmcmds(&vcset); +out: vrele(vp); - return error; } Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.11 src/sys/ufs/chfs/chfs_vfsops.c:1.11.2.1 --- src/sys/ufs/chfs/chfs_vfsops.c:1.11 Wed Apr 16 18:55:19 2014 +++ src/sys/ufs/chfs/chfs_vfsops.c Mon Dec 29 16:35:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.11 2014/04/16 18:55:19 maxv Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.11.2.1 2014/12/29 16:35:51 martin Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -152,9 +152,12 @@ chfs_mount(struct mount *mp, } /* Look up the name and verify that it's sane. */ NDINIT(&nd, LOOKUP, FOLLOW, pb); - if ((err = namei(&nd)) != 0 ) + if ((err = namei(&nd)) != 0 ) { + pathbuf_destroy(pb); return (err); + } devvp = nd.ni_vp; + pathbuf_destroy(pb); /* Be sure this is a valid block device */ if (devvp->v_type != VBLK)