PERFORCE change 97825 for review

John Baldwin jhb at FreeBSD.org
Thu May 25 14:20:35 PDT 2006


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

Change 97825 by jhb at jhb_mutex on 2006/05/25 21:19:00

	- linker_reference_module() is never called with the KLD_LOCK held
	  anymore.
	- Use securelevel_gt() rather than checking the securelevel variable
	  directly.

Affected files ...

.. //depot/projects/smpng/sys/kern/kern_linker.c#58 edit

Differences ...

==== //depot/projects/smpng/sys/kern/kern_linker.c#58 (text+ko) ====

@@ -356,8 +356,8 @@
 	int foundfile, error;
 
 	/* Refuse to load modules if securelevel raised */
-	if (securelevel > 0)
-		return (EPERM);
+	if ((error = securelevel_gt(curthread->td_ucred, 0)) != 0)
+		return (error);
 
 	KLD_LOCK_ASSERT();
 	lf = linker_find_file_by_name(filename);
@@ -427,21 +427,17 @@
 	modlist_t mod;
 	int error, locked;
 
-	locked = KLD_LOCKED();
-	if (!locked)
-		KLD_LOCK();
+	KLD_LOCK();
 	if ((mod = modlist_lookup2(modname, verinfo)) != NULL) {
 		*result = mod->container;
 		(*result)->refs++;
-		if (!locked)
-			KLD_UNLOCK();
+		KLD_UNLOCK();
 		return (0);
 	}
 
 	error = linker_load_module(NULL, modname, NULL, verinfo,
 	    result);
-	if (!locked)
-		KLD_UNLOCK();
+	KLD_UNLOCK();
 	return (error);
 }
 
@@ -542,8 +538,8 @@
 	int error, i;
 
 	/* Refuse to unload modules if securelevel raised. */
-	if (securelevel > 0)
-		return (EPERM);
+	if ((error = securelevel_gt(curthread->td_ucred, 0)) != 0)
+		return (error);
 #ifdef MAC
 	error = mac_check_kld_unload(curthread->td_ucred);
 	if (error)


More information about the p4-projects mailing list