mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-18 08:52:42 +01:00
Close out PR #507 (loading LM_MISC pseudo-lkms twice crashes system).
For the LKM_E_LOAD case of the DISPATCH() macro, use lkmexists() to make sure we don't have another instance the module we're trying to load already loaded _before_ calling the module's load() function. If lkmexists() returns true, return EEXIST without trying to load the module. For most types of modules, the individual dispatch functions in the kernel check for duplicated modules, but for LM_MISC we can't trust the module to do the checks itself. Currently, the kernel does do an lkmexists() check on LM_MISC modules, but not until after the module's load() function has been called, which is too late for it to do any good. If the load() function does irreversible things to the kernel, the belated lkmexists() check forces an unload() and a crash.
This commit is contained in:
parent
ee0aa83a01
commit
0932a90b65
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9252
@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: lkm.h,v 1.3 1994/09/27 20:39:48 phk Exp $
|
||||
* lkm.h,v 1.5 1995/04/20 05:08:51 wpaul Exp
|
||||
*/
|
||||
|
||||
#ifndef _SYS_LKM_H_
|
||||
@ -272,6 +272,8 @@ extern int nosys();
|
||||
int error; \
|
||||
case LKM_E_LOAD: \
|
||||
lkmtp->private.lkm_any = (struct lkm_any *)&_module; \
|
||||
if (lkmexists(lkmtp)) /* !!! */ \
|
||||
return EEXIST; \
|
||||
if (load != nosys && (error = load(lkmtp, cmd))) \
|
||||
return error; \
|
||||
break; \
|
||||
@ -287,6 +289,7 @@ extern int nosys();
|
||||
return lkmdispatch(lkmtp, cmd);
|
||||
|
||||
int lkmdispatch __P((struct lkm_table *lkmtp, int cmd));
|
||||
int lkmexists __P((struct lkm_table *lkmtp));
|
||||
|
||||
#endif /* KERNEL */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user