PERFORCE change 66517 for review

Sam Leffler sam at FreeBSD.org
Sun Dec 5 22:18:54 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=66517

Change 66517 by sam at sam_ebb on 2004/12/06 06:17:59

	o add os-specific wrapper for loading modules
	o acquire Giant around call to linker_load_module now that
	  ioctl doesn't grab it for us; this generates LOR's big time
	  (as does holding the softc lock over the blocking mallocs)

Affected files ...

.. //depot/projects/wifi/sys/net80211/ieee80211_crypto.c#5 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_freebsd.c#7 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_freebsd.h#9 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_proto.c#15 edit

Differences ...

==== //depot/projects/wifi/sys/net80211/ieee80211_crypto.c#5 (text+ko) ====

@@ -38,7 +38,6 @@
  */
 #include <sys/param.h>
 #include <sys/mbuf.h>   
-#include <sys/linker.h>
 
 #include <sys/socket.h>
 
@@ -249,9 +248,7 @@
 			IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
 				"%s: unregistered cipher %u, load module %s\n",
 				__func__, cipher, cipher_modnames[cipher]);
-			/* XXX check return */
-			linker_load_module(cipher_modnames[cipher], NULL,
-				NULL, NULL, NULL);
+			ieee80211_load_module(cipher_modnames[cipher]);
 			/*
 			 * If cipher module loaded it should immediately
 			 * call ieee80211_crypto_register which will fill

==== //depot/projects/wifi/sys/net80211/ieee80211_freebsd.c#7 (text+ko) ====

@@ -34,8 +34,10 @@
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h> 
+#include <sys/linker.h>
 #include <sys/mbuf.h>   
 #include <sys/module.h>
+#include <sys/proc.h>
 #include <sys/sysctl.h>
 
 #include <sys/socket.h>
@@ -295,6 +297,18 @@
 	}
 }
 
+void
+ieee80211_load_module(const char *modname)
+{
+	struct thread *td = curthread;
+
+	if (suser(td) == 0 && securelevel_gt(td->td_ucred, 0) == 0) {
+		mtx_lock(&Giant);
+		(void) linker_load_module(modname, NULL, NULL, NULL, NULL);
+		mtx_unlock(&Giant);
+	}
+}
+
 /*
  * Module glue.
  *

==== //depot/projects/wifi/sys/net80211/ieee80211_freebsd.h#9 (text+ko) ====

@@ -179,6 +179,8 @@
 void	ieee80211_sysctl_attach(struct ieee80211com *);
 void	ieee80211_sysctl_detach(struct ieee80211com *);
 
+void	ieee80211_load_module(const char *);
+
 /* XXX this stuff belongs elsewhere */
 /*
  * Message formats for messages from the net80211 layer to user

==== //depot/projects/wifi/sys/net80211/ieee80211_proto.c#15 (text+ko) ====

@@ -42,7 +42,6 @@
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h> 
-#include <sys/linker.h>
  
 #include <sys/socket.h>
 
@@ -181,10 +180,8 @@
 {
 	if (auth >= IEEE80211_AUTH_MAX)
 		return NULL;
-	if (authenticators[auth] == NULL) {
-		/* XXX check return */
-		linker_load_module(auth_modnames[auth], NULL, NULL, NULL, NULL);
-	}
+	if (authenticators[auth] == NULL)
+		ieee80211_load_module(auth_modnames[auth]);
 	return authenticators[auth];
 }
 
@@ -231,7 +228,7 @@
 ieee80211_aclator_get(const char *name)
 {
 	if (acl == NULL)
-		linker_load_module("wlan_acl", NULL, NULL, NULL, NULL);
+		ieee80211_load_module("wlan_acl");
 	return acl != NULL && strcmp(acl->iac_name, name) == 0 ? acl : NULL;
 }
 


More information about the p4-projects mailing list