Subject: kern/35412: opencrypto framework is reinitialized when calling crypto_get_driverid ()
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <daniel@NetBSD.org>
List: netbsd-bugs
Date: 01/12/2007 08:55:00
>Number:         35412
>Category:       kern
>Synopsis:       opencrypto framework is reinitialized when calling crypto_get_driverid()
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 12 08:55:00 +0000 2007
>Originator:     Daniel de Kok
>Release:        NetBSD 4.99.7
>Organization:
	
>Environment:
	
	
System: NetBSD liza.taickim.net 4.99.7 NetBSD 4.99.7 (PADLOCK) #41: Fri Jan 12 09:30:40 CET 2007  daniel@mindbender.taickim.net:/home/daniel/src-current/sys/arch/i386/compile/obj/PADLOCK i386
Architecture: i386
Machine: i386
>Description:
	crypto_init does not call crypto_init0 only once, because the marker
	created with ONCE_DECL() is local. This results in reinitializing
	the driver list when crypto_get_driverid() (and leaks memory).
>How-To-Repeat:
	Add an additional crypto driver, and boot the kernel with the
	verbose flag, and you will see that each driver gets hid 0.
>Fix:
	This patch makes the marker static, it would be great if someone
	could 'ack' it before I commit this.

Index: sys/opencrypto/crypto.c
===================================================================
RCS file: /cvsroot/src/sys/opencrypto/crypto.c,v
retrieving revision 1.17
diff -b -u -r1.17 crypto.c
--- sys/opencrypto/crypto.c	16 Nov 2006 01:33:51 -0000	1.17
+++ sys/opencrypto/crypto.c	12 Jan 2007 08:41:34 -0000
@@ -242,7 +242,7 @@
 void
 crypto_init(void)
 {
-	ONCE_DECL(crypto_init_once);
+	static ONCE_DECL(crypto_init_once);
 
 	RUN_ONCE(&crypto_init_once, crypto_init0);
 }

>Unformatted: