Module Name:    src
Committed By:   riz
Date:           Thu Mar 14 22:33:16 UTC 2013

Modified Files:
        src/sys/dist/ipf/netinet [netbsd-6]: fil.c ip_lookup.c

Log Message:
Apply patches (requested by chs in ticket #844):
src/sys/dist/ipf/netinet/fil.c                  patch
src/sys/dist/ipf/netinet/ip_lookup.c            patch

        Fix some problems in IPF where a lock may be left locked
        when it should be released or unlocked when it's not locked.
        [chs, ticket #844]


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.53.2.1 src/sys/dist/ipf/netinet/fil.c
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/dist/ipf/netinet/ip_lookup.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/dist/ipf/netinet/fil.c
diff -u src/sys/dist/ipf/netinet/fil.c:1.53 src/sys/dist/ipf/netinet/fil.c:1.53.2.1
--- src/sys/dist/ipf/netinet/fil.c:1.53	Wed Feb 15 17:55:21 2012
+++ src/sys/dist/ipf/netinet/fil.c	Thu Mar 14 22:33:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fil.c,v 1.53 2012/02/15 17:55:21 riz Exp $	*/
+/*	$NetBSD: fil.c,v 1.53.2.1 2013/03/14 22:33:15 riz Exp $	*/
 
 /*
  * Copyright (C) 1993-2010 by Darren Reed.
@@ -157,7 +157,7 @@ struct file;
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.53 2012/02/15 17:55:21 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.53.2.1 2013/03/14 22:33:15 riz Exp $");
 #else
 static const char sccsid[] = "@(#)fil.c	1.36 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: fil.c,v 2.243.2.154 2010/02/24 10:07:57 darrenr Exp";
@@ -6617,9 +6617,6 @@ ipf_deltoken(int type, int uid, void *pt
 /* matches the tuple (type, uid, ptr).  If one cannot be found then one is  */
 /* allocated.  If one is found then it is moved to the top of the list of   */
 /* currently active tokens.                                                 */
-/*                                                                          */
-/* NOTE: It is by design that this function returns holding a read lock on  */
-/*       ipf_tokens.  Callers must make sure they release it!               */
 /* ------------------------------------------------------------------------ */
 ipftoken_t *
 ipf_findtoken(int type, int uid, void *ptr)
@@ -6638,8 +6635,10 @@ ipf_findtoken(int type, int uid, void *p
 	if (it == NULL) {
 		it = new;
 		new = NULL;
-		if (it == NULL)
+		if (it == NULL) {
+			RWLOCK_EXIT(&ipf_tokens);
 			return NULL;
+		}
 		it->ipt_data = NULL;
 		it->ipt_ctx = ptr;
 		it->ipt_uid = uid;
@@ -7014,7 +7013,6 @@ ipf_genericiter(void *data, int uid, voi
 		RWLOCK_EXIT(&ipf_tokens);
 	} else
 		error = EFAULT;
-	RWLOCK_EXIT(&ipf_tokens);
 
 	return error;
 }

Index: src/sys/dist/ipf/netinet/ip_lookup.c
diff -u src/sys/dist/ipf/netinet/ip_lookup.c:1.19 src/sys/dist/ipf/netinet/ip_lookup.c:1.19.2.1
--- src/sys/dist/ipf/netinet/ip_lookup.c:1.19	Wed Feb 15 17:55:22 2012
+++ src/sys/dist/ipf/netinet/ip_lookup.c	Thu Mar 14 22:33:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_lookup.c,v 1.19 2012/02/15 17:55:22 riz Exp $	*/
+/*	$NetBSD: ip_lookup.c,v 1.19.2.1 2013/03/14 22:33:16 riz Exp $	*/
 
 /*
  * Copyright (C) 2002-2003 by Darren Reed.
@@ -67,7 +67,7 @@ struct file;
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_lookup.c,v 1.19 2012/02/15 17:55:22 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_lookup.c,v 1.19.2.1 2013/03/14 22:33:16 riz Exp $");
 #else
 static const char rcsid[] = "@(#)Id: ip_lookup.c,v 2.35.2.22 2010/01/31 16:22:55 darrenr Exp";
 #endif
@@ -612,7 +612,6 @@ iplookup_iterate(void *data, int uid, vo
 	SPL_SCHED(s);
 	token = ipf_findtoken(iter.ili_key, uid, ctx);
 	if (token == NULL) {
-		RWLOCK_EXIT(&ipf_tokens);
 		SPL_X(s);
 		return ESRCH;
 	}

Reply via email to