Module Name:    src
Committed By:   snj
Date:           Sat Aug 12 04:18:10 UTC 2017

Modified Files:
        src/sys/compat/common [netbsd-7]: vfs_syscalls_12.c vfs_syscalls_43.c
        src/sys/compat/ibcs2 [netbsd-7]: ibcs2_misc.c
        src/sys/compat/linux/common [netbsd-7]: linux_file64.c linux_misc.c
        src/sys/compat/linux32/common [netbsd-7]: linux32_dirent.c
        src/sys/compat/osf1 [netbsd-7]: osf1_file.c
        src/sys/compat/sunos [netbsd-7]: sunos_misc.c
        src/sys/compat/sunos32 [netbsd-7]: sunos32_misc.c
        src/sys/compat/svr4 [netbsd-7]: svr4_misc.c
        src/sys/compat/svr4_32 [netbsd-7]: svr4_32_misc.c
        src/sys/rump/kern/lib/libsys_sunos [netbsd-7]: rump_sunos_compat.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1479):
        sys/compat/common/vfs_syscalls_12.c: revision 1.34
        sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
        sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
        sys/compat/sunos32/sunos32_misc.c: revision 1.78
        sys/compat/linux/common/linux_misc.c: revision 1.239
        sys/compat/osf1/osf1_file.c: revision 1.44
        sys/compat/common/vfs_syscalls_43.c: revision 1.60
        sys/compat/svr4/svr4_misc.c: revision 1.158
        sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
        sys/compat/linux/common/linux_file64.c: revision 1.59
        sys/compat/linux32/common/linux32_dirent.c: revision 1.18
        sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
>From Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.30.4.1 src/sys/compat/common/vfs_syscalls_12.c
cvs rdiff -u -r1.56.4.1 -r1.56.4.2 src/sys/compat/common/vfs_syscalls_43.c
cvs rdiff -u -r1.112 -r1.112.12.1 src/sys/compat/ibcs2/ibcs2_misc.c
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/compat/linux/common/linux_file64.c
cvs rdiff -u -r1.229.2.1 -r1.229.2.2 src/sys/compat/linux/common/linux_misc.c
cvs rdiff -u -r1.13 -r1.13.28.1 \
    src/sys/compat/linux32/common/linux32_dirent.c
cvs rdiff -u -r1.41.28.1 -r1.41.28.2 src/sys/compat/osf1/osf1_file.c
cvs rdiff -u -r1.168 -r1.168.34.1 src/sys/compat/sunos/sunos_misc.c
cvs rdiff -u -r1.74 -r1.74.22.1 src/sys/compat/sunos32/sunos32_misc.c
cvs rdiff -u -r1.155 -r1.155.28.1 src/sys/compat/svr4/svr4_misc.c
cvs rdiff -u -r1.74 -r1.74.28.1 src/sys/compat/svr4_32/svr4_32_misc.c
cvs rdiff -u -r1.1 -r1.1.14.1 \
    src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.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_12.c
diff -u src/sys/compat/common/vfs_syscalls_12.c:1.30 src/sys/compat/common/vfs_syscalls_12.c:1.30.4.1
--- src/sys/compat/common/vfs_syscalls_12.c:1.30	Fri Jan 24 22:11:46 2014
+++ src/sys/compat/common/vfs_syscalls_12.c	Sat Aug 12 04:18:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_12.c,v 1.30 2014/01/24 22:11:46 christos Exp $	*/
+/*	$NetBSD: vfs_syscalls_12.c,v 1.30.4.1 2017/08/12 04:18:09 snj Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.30 2014/01/24 22:11:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.30.4.1 2017/08/12 04:18:09 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -171,8 +171,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic(__func__);
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)

Index: src/sys/compat/common/vfs_syscalls_43.c
diff -u src/sys/compat/common/vfs_syscalls_43.c:1.56.4.1 src/sys/compat/common/vfs_syscalls_43.c:1.56.4.2
--- src/sys/compat/common/vfs_syscalls_43.c:1.56.4.1	Sat Aug 27 15:10:59 2016
+++ src/sys/compat/common/vfs_syscalls_43.c	Sat Aug 12 04:18:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_43.c,v 1.56.4.1 2016/08/27 15:10:59 bouyer Exp $	*/
+/*	$NetBSD: vfs_syscalls_43.c,v 1.56.4.2 2017/08/12 04:18:09 snj Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.56.4.1 2016/08/27 15:10:59 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.56.4.2 2017/08/12 04:18:09 snj Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -450,8 +450,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic(__func__);
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)

Index: src/sys/compat/ibcs2/ibcs2_misc.c
diff -u src/sys/compat/ibcs2/ibcs2_misc.c:1.112 src/sys/compat/ibcs2/ibcs2_misc.c:1.112.12.1
--- src/sys/compat/ibcs2/ibcs2_misc.c:1.112	Tue Oct  2 01:44:27 2012
+++ src/sys/compat/ibcs2/ibcs2_misc.c	Sat Aug 12 04:18:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibcs2_misc.c,v 1.112 2012/10/02 01:44:27 christos Exp $	*/
+/*	$NetBSD: ibcs2_misc.c,v 1.112.12.1 2017/08/12 04:18:09 snj Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.112 2012/10/02 01:44:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.112.12.1 2017/08/12 04:18:09 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -427,8 +427,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("ibcs2_getdents: bad reclen");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (cookie && (*cookie >> 32) != 0) {
 			compat_offseterr(vp, "ibcs2_getdents");
 			error = EINVAL;

Index: src/sys/compat/linux/common/linux_file64.c
diff -u src/sys/compat/linux/common/linux_file64.c:1.55 src/sys/compat/linux/common/linux_file64.c:1.55.4.1
--- src/sys/compat/linux/common/linux_file64.c:1.55	Fri Dec 27 14:17:11 2013
+++ src/sys/compat/linux/common/linux_file64.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_file64.c,v 1.55 2013/12/27 14:17:11 njoly Exp $	*/
+/*	$NetBSD: linux_file64.c,v 1.55.4.1 2017/08/12 04:18:10 snj Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.55 2013/12/27 14:17:11 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.55.4.1 2017/08/12 04:18:10 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -325,8 +325,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("linux_readdir");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.229.2.1 src/sys/compat/linux/common/linux_misc.c:1.229.2.2
--- src/sys/compat/linux/common/linux_misc.c:1.229.2.1	Mon Apr 17 05:19:09 2017
+++ src/sys/compat/linux/common/linux_misc.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.229.2.1 2017/04/17 05:19:09 snj Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.229.2.2 2017/08/12 04:18:10 snj Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.229.2.1 2017/04/17 05:19:09 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.229.2.2 2017/08/12 04:18:10 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -745,8 +745,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("linux_readdir");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)

Index: src/sys/compat/linux32/common/linux32_dirent.c
diff -u src/sys/compat/linux32/common/linux32_dirent.c:1.13 src/sys/compat/linux32/common/linux32_dirent.c:1.13.28.1
--- src/sys/compat/linux32/common/linux32_dirent.c:1.13	Fri Oct 14 09:23:29 2011
+++ src/sys/compat/linux32/common/linux32_dirent.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_dirent.c,v 1.13 2011/10/14 09:23:29 hannken Exp $ */
+/*	$NetBSD: linux32_dirent.c,v 1.13.28.1 2017/08/12 04:18:10 snj Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.13 2011/10/14 09:23:29 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.13.28.1 2017/08/12 04:18:10 snj Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -178,8 +178,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("linux32_readdir");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)

Index: src/sys/compat/osf1/osf1_file.c
diff -u src/sys/compat/osf1/osf1_file.c:1.41.28.1 src/sys/compat/osf1/osf1_file.c:1.41.28.2
--- src/sys/compat/osf1/osf1_file.c:1.41.28.1	Wed Aug 27 15:29:29 2014
+++ src/sys/compat/osf1/osf1_file.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: osf1_file.c,v 1.41.28.1 2014/08/27 15:29:29 msaitoh Exp $ */
+/* $NetBSD: osf1_file.c,v 1.41.28.2 2017/08/12 04:18:10 snj Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.41.28.1 2014/08/27 15:29:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.41.28.2 2017/08/12 04:18:10 snj Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_syscall_debug.h"
@@ -201,8 +201,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("osf1_sys_getdirentries: bad reclen");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (cookie)
 			off = *cookie++; /* each entry points to the next */
 		else

Index: src/sys/compat/sunos/sunos_misc.c
diff -u src/sys/compat/sunos/sunos_misc.c:1.168 src/sys/compat/sunos/sunos_misc.c:1.168.34.1
--- src/sys/compat/sunos/sunos_misc.c:1.168	Thu Jun 24 13:03:07 2010
+++ src/sys/compat/sunos/sunos_misc.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunos_misc.c,v 1.168 2010/06/24 13:03:07 hannken Exp $	*/
+/*	$NetBSD: sunos_misc.c,v 1.168.34.1 2017/08/12 04:18:10 snj Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.168 2010/06/24 13:03:07 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.168.34.1 2017/08/12 04:18:10 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -414,8 +414,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("sunos_getdents");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if ((*cookie >> 32) != 0) {
 			compat_offseterr(vp, "sunos_getdents");
 			error = EINVAL;

Index: src/sys/compat/sunos32/sunos32_misc.c
diff -u src/sys/compat/sunos32/sunos32_misc.c:1.74 src/sys/compat/sunos32/sunos32_misc.c:1.74.22.1
--- src/sys/compat/sunos32/sunos32_misc.c:1.74	Sun Feb 12 16:34:11 2012
+++ src/sys/compat/sunos32/sunos32_misc.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sunos32_misc.c,v 1.74 2012/02/12 16:34:11 matt Exp $	*/
+/*	$NetBSD: sunos32_misc.c,v 1.74.22.1 2017/08/12 04:18:10 snj Exp $	*/
 /* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp	*/
 
 /*
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.74 2012/02/12 16:34:11 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.74.22.1 2017/08/12 04:18:10 snj Exp $");
 
 #define COMPAT_SUNOS 1
 
@@ -659,8 +659,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("sunos_getdents");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (cookie && (*cookie >> 32) != 0) {
 			compat_offseterr(vp, "sunos_getdents");
 			error = EINVAL;

Index: src/sys/compat/svr4/svr4_misc.c
diff -u src/sys/compat/svr4/svr4_misc.c:1.155 src/sys/compat/svr4/svr4_misc.c:1.155.28.1
--- src/sys/compat/svr4/svr4_misc.c:1.155	Tue Sep 27 00:52:55 2011
+++ src/sys/compat/svr4/svr4_misc.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_misc.c,v 1.155 2011/09/27 00:52:55 christos Exp $	 */
+/*	$NetBSD: svr4_misc.c,v 1.155.28.1 2017/08/12 04:18:10 snj Exp $	 */
 
 /*-
  * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.155 2011/09/27 00:52:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.155.28.1 2017/08/12 04:18:10 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -264,8 +264,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("svr4_getdents64: bad reclen");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)
@@ -388,8 +390,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("svr4_getdents: bad reclen");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (cookie)
 			off = *cookie++; /* each entry points to the next */
 		else

Index: src/sys/compat/svr4_32/svr4_32_misc.c
diff -u src/sys/compat/svr4_32/svr4_32_misc.c:1.74 src/sys/compat/svr4_32/svr4_32_misc.c:1.74.28.1
--- src/sys/compat/svr4_32/svr4_32_misc.c:1.74	Tue Sep 27 00:56:14 2011
+++ src/sys/compat/svr4_32/svr4_32_misc.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_32_misc.c,v 1.74 2011/09/27 00:56:14 christos Exp $	 */
+/*	$NetBSD: svr4_32_misc.c,v 1.74.28.1 2017/08/12 04:18:10 snj Exp $	 */
 
 /*-
  * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.74 2011/09/27 00:56:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.74.28.1 2017/08/12 04:18:10 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -263,8 +263,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("svr4_32_getdents64: bad reclen");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if (bdp->d_fileno == 0) {
 			inp += reclen;	/* it is a hole; squish it out */
 			if (cookie)

Index: src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c
diff -u src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c:1.1 src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c:1.1.14.1
--- src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c:1.1	Tue Apr  9 13:08:33 2013
+++ src/sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c	Sat Aug 12 04:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump_sunos_compat.c,v 1.1 2013/04/09 13:08:33 pooka Exp $	*/
+/*	$NetBSD: rump_sunos_compat.c,v 1.1.14.1 2017/08/12 04:18:10 snj Exp $	*/
 
 /*
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -313,8 +313,10 @@ again:
 	for (cookie = cookiebuf; len > 0; len -= reclen) {
 		bdp = (struct dirent *)inp;
 		reclen = bdp->d_reclen;
-		if (reclen & 3)
-			panic("sunos_getdents");
+		if (reclen & 3) {
+			error = EIO;
+			goto out;
+		}
 		if ((*cookie >> 32) != 0) {
 			printf("rump_sunos_sys_getdents: offset too large\n");
 			error = EINVAL;

Reply via email to