Fri Jan 24 15:11:09 2014 UTC ()
As requested by mrg@, since there is still a small window during which
the in-module ref-counting can fail, completely disable auto-unload.


(pgoyette)
diff -r1.74 -r1.75 src/sys/opencrypto/cryptodev.c

cvs diff -r1.74 -r1.75 src/sys/opencrypto/cryptodev.c (expand / switch to unified diff)

--- src/sys/opencrypto/cryptodev.c 2014/01/21 20:33:01 1.74
+++ src/sys/opencrypto/cryptodev.c 2014/01/24 15:11:09 1.75
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cryptodev.c,v 1.74 2014/01/21 20:33:01 pgoyette Exp $ */ 1/* $NetBSD: cryptodev.c,v 1.75 2014/01/24 15:11:09 pgoyette Exp $ */
2/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ 2/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
3/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */ 3/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
4 4
5/*- 5/*-
6 * Copyright (c) 2008 The NetBSD Foundation, Inc. 6 * Copyright (c) 2008 The NetBSD Foundation, Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * This code is derived from software contributed to The NetBSD Foundation 9 * This code is derived from software contributed to The NetBSD Foundation
10 * by Coyote Point Systems, Inc. 10 * by Coyote Point Systems, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -54,27 +54,27 @@ @@ -54,27 +54,27 @@
54 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
58 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 * 59 *
60 * Effort sponsored in part by the Defense Advanced Research Projects 60 * Effort sponsored in part by the Defense Advanced Research Projects
61 * Agency (DARPA) and Air Force Research Laboratory, Air Force 61 * Agency (DARPA) and Air Force Research Laboratory, Air Force
62 * Materiel Command, USAF, under agreement number F30602-01-2-0537. 62 * Materiel Command, USAF, under agreement number F30602-01-2-0537.
63 * 63 *
64 */ 64 */
65 65
66#include <sys/cdefs.h> 66#include <sys/cdefs.h>
67__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.74 2014/01/21 20:33:01 pgoyette Exp $"); 67__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.75 2014/01/24 15:11:09 pgoyette Exp $");
68 68
69#include <sys/param.h> 69#include <sys/param.h>
70#include <sys/systm.h> 70#include <sys/systm.h>
71#include <sys/kmem.h> 71#include <sys/kmem.h>
72#include <sys/malloc.h> 72#include <sys/malloc.h>
73#include <sys/mbuf.h> 73#include <sys/mbuf.h>
74#include <sys/pool.h> 74#include <sys/pool.h>
75#include <sys/sysctl.h> 75#include <sys/sysctl.h>
76#include <sys/file.h> 76#include <sys/file.h>
77#include <sys/filedesc.h> 77#include <sys/filedesc.h>
78#include <sys/errno.h> 78#include <sys/errno.h>
79#include <sys/md5.h> 79#include <sys/md5.h>
80#include <sys/sha1.h> 80#include <sys/sha1.h>
@@ -2214,21 +2214,26 @@ crypto_modcmd(modcmd_t cmd, void *arg) @@ -2214,21 +2214,26 @@ crypto_modcmd(modcmd_t cmd, void *arg)
2214 error = config_cfdata_detach(crypto_cfdata); 2214 error = config_cfdata_detach(crypto_cfdata);
2215 if (error) { 2215 if (error) {
2216 return error; 2216 return error;
2217 } 2217 }
2218 2218
2219 config_cfattach_detach(crypto_cd.cd_name, &crypto_ca); 2219 config_cfattach_detach(crypto_cd.cd_name, &crypto_ca);
2220 config_cfdriver_detach(&crypto_cd); 2220 config_cfdriver_detach(&crypto_cd);
2221 devsw_detach(NULL, &crypto_cdevsw); 2221 devsw_detach(NULL, &crypto_cdevsw);
2222#endif 2222#endif
2223 2223
2224 return error; 2224 return error;
2225#ifdef _MODULE 2225#ifdef _MODULE
2226 case MODULE_CMD_AUTOUNLOAD: 2226 case MODULE_CMD_AUTOUNLOAD:
 2227#if 0 /*
 2228 * XXX Completely disable auto-unload for now, since there is still
 2229 * XXX a (small) window where in-module ref-counting doesn't help
 2230 */
2227 if (crypto_refcount != 0) 2231 if (crypto_refcount != 0)
 2232#endif
2228 return EBUSY; 2233 return EBUSY;
2229 /* FALLTHROUGH */ 2234 /* FALLTHROUGH */
2230#endif 2235#endif
2231 default: 2236 default:
2232 return ENOTTY; 2237 return ENOTTY;
2233 } 2238 }
2234} 2239}