Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat When implementing "read directory", when there ar...
details: https://anonhg.NetBSD.org/src/rev/1c8cce4f8c97
branches: trunk
changeset: 752675:1c8cce4f8c97
user: he <he%NetBSD.org@localhost>
date: Wed Mar 03 08:20:38 2010 +0000
description:
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.
diffstat:
sys/compat/common/vfs_syscalls_30.c | 10 +++++++---
sys/compat/ibcs2/ibcs2_misc.c | 16 ++++++++++++----
sys/compat/irix/irix_dirent.c | 16 ++++++++++++----
sys/compat/linux/common/linux_file64.c | 10 +++++++---
sys/compat/linux/common/linux_misc.c | 10 +++++++---
sys/compat/linux32/common/linux32_dirent.c | 10 +++++++---
sys/compat/osf1/osf1_file.c | 10 +++++++---
sys/compat/sunos/sunos_misc.c | 10 +++++++---
sys/compat/sunos32/sunos32_misc.c | 10 +++++++---
sys/compat/svr4/svr4_misc.c | 16 ++++++++++++----
sys/compat/svr4_32/svr4_32_misc.c | 16 ++++++++++++----
11 files changed, 97 insertions(+), 37 deletions(-)
diffs (truncated from 408 to 300 lines):
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/common/vfs_syscalls_30.c
--- a/sys/compat/common/vfs_syscalls_30.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/common/vfs_syscalls_30.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls_30.c,v 1.30 2009/01/26 13:00:04 njoly Exp $ */
+/* $NetBSD: vfs_syscalls_30.c,v 1.31 2010/03/03 08:20:38 he 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.30 2009/01/26 13:00:04 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.31 2010/03/03 08:20:38 he Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -305,8 +305,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:
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/ibcs2/ibcs2_misc.c
--- a/sys/compat/ibcs2/ibcs2_misc.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/ibcs2/ibcs2_misc.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ibcs2_misc.c,v 1.109 2009/11/04 21:23:02 rmind Exp $ */
+/* $NetBSD: ibcs2_misc.c,v 1.110 2010/03/03 08:20:39 he Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -95,7 +95,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.109 2009/11/04 21:23:02 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.110 2010/03/03 08:20:39 he Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -472,8 +472,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:
@@ -602,8 +606,12 @@
resid -= ibcs2_reclen;
}
/* 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:
*retval = SCARG(uap, nbytes) - resid;
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/irix/irix_dirent.c
--- a/sys/compat/irix/irix_dirent.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/irix/irix_dirent.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_dirent.c,v 1.23 2008/04/28 20:23:41 martin Exp $ */
+/* $NetBSD: irix_dirent.c,v 1.24 2010/03/03 08:20:38 he Exp $ */
/*-
* Copyright (c) 1994, 2001, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.23 2008/04/28 20:23:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.24 2010/03/03 08:20:38 he Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@@ -173,8 +173,12 @@
}
/* if we squished out the whole block, try again */
- if (outp == (char *)SCARG(uap, buf))
+ if (outp == (char *)SCARG(uap, buf)) {
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ cookiebuf = NULL;
goto again;
+ }
fp->f_offset = off; /* update the vnode offset */
eof:
@@ -324,8 +328,12 @@
}
/* if we squished out the whole block, try again */
- if (outp == (char *)SCARG(uap, buf))
+ if (outp == (char *)SCARG(uap, buf)) {
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ cookiebuf = NULL;
goto again;
+ }
fp->f_offset = off; /* update the vnode offset */
eof:
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/linux/common/linux_file64.c
--- a/sys/compat/linux/common/linux_file64.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/linux/common/linux_file64.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file64.c,v 1.49 2009/05/15 17:02:54 pooka Exp $ */
+/* $NetBSD: linux_file64.c,v 1.50 2010/03/03 08:20:38 he 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.49 2009/05/15 17:02:54 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.50 2010/03/03 08:20:38 he Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -336,8 +336,12 @@
}
/* if we squished out the whole block, try again */
- if (outp == (void *)SCARG(uap, dent))
+ if (outp == (void *)SCARG(uap, dent)) {
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ cookiebuf = NULL;
goto again;
+ }
fp->f_offset = off; /* update the vnode offset */
eof:
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/linux/common/linux_misc.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc.c,v 1.213 2009/12/05 20:11:17 pooka Exp $ */
+/* $NetBSD: linux_misc.c,v 1.214 2010/03/03 08:20:38 he 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.213 2009/12/05 20:11:17 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.214 2010/03/03 08:20:38 he Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -803,8 +803,12 @@
}
/* if we squished out the whole block, try again */
- if (outp == (void *)SCARG(uap, dent))
+ if (outp == (void *)SCARG(uap, dent)) {
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ cookiebuf = NULL;
goto again;
+ }
fp->f_offset = off; /* update the vnode offset */
if (oldcall)
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/linux32/common/linux32_dirent.c
--- a/sys/compat/linux32/common/linux32_dirent.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/linux32/common/linux32_dirent.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_dirent.c,v 1.9 2009/07/22 15:49:29 njoly Exp $ */
+/* $NetBSD: linux32_dirent.c,v 1.10 2010/03/03 08:20:38 he 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.9 2009/07/22 15:49:29 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.10 2010/03/03 08:20:38 he Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -229,8 +229,12 @@
}
/* if we squished out the whole block, try again */
- if (outp == (void *)SCARG_P32(uap, dent))
+ if (outp == (void *)SCARG_P32(uap, dent)) {
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ cookiebuf = NULL;
goto again;
+ }
fp->f_offset = off; /* update the vnode offset */
if (oldcall)
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/osf1/osf1_file.c
--- a/sys/compat/osf1/osf1_file.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/osf1/osf1_file.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: osf1_file.c,v 1.37 2009/08/09 22:49:01 haad Exp $ */
+/* $NetBSD: osf1_file.c,v 1.38 2010/03/03 08:20:38 he 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.37 2009/08/09 22:49:01 haad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: osf1_file.c,v 1.38 2010/03/03 08:20:38 he Exp $");
#if defined(_KERNEL_OPT)
#include "opt_syscall_debug.h"
@@ -232,8 +232,12 @@
}
/* if we squished out the whole block, try again */
- if (outp == (char *)SCARG(uap, buf))
+ if (outp == (char *)SCARG(uap, buf)) {
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ cookiebuf = NULL;
goto again;
+ }
fp->f_offset = off; /* update the vnode offset */
eof:
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/sunos/sunos_misc.c
--- a/sys/compat/sunos/sunos_misc.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/sunos/sunos_misc.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunos_misc.c,v 1.165 2009/06/29 05:08:16 dholland Exp $ */
+/* $NetBSD: sunos_misc.c,v 1.166 2010/03/03 08:20:39 he Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.165 2009/06/29 05:08:16 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.166 2010/03/03 08:20:39 he Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -459,8 +459,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:
diff -r f116c7b37806 -r 1c8cce4f8c97 sys/compat/sunos32/sunos32_misc.c
--- a/sys/compat/sunos32/sunos32_misc.c Wed Mar 03 06:57:53 2010 +0000
+++ b/sys/compat/sunos32/sunos32_misc.c Wed Mar 03 08:20:38 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunos32_misc.c,v 1.68 2010/03/02 21:09:21 pooka Exp $ */
+/* $NetBSD: sunos32_misc.c,v 1.69 2010/03/03 08:20:39 he 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.68 2010/03/02 21:09:21 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.69 2010/03/03 08:20:39 he Exp $");
Home |
Main Index |
Thread Index |
Old Index