implement support for forced LKM load, which makes the kernel skip
the version checks, using new -f flag and LMFORCE ioctl Hopefully the description in the manpage is discouraging enough so that nobody would dare even _think_ of using forced loads. A warning message is written to stderr when this is used, just in case.
This commit is contained in:
parent
ab4849bbde
commit
ade4df3adc
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: modload.8,v 1.23 2003/02/25 10:34:59 wiz Exp $
|
||||
.\" $NetBSD: modload.8,v 1.24 2003/09/06 19:23:21 jdolecek Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1993 Christopher G. Demetriou
|
||||
.\" All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
.\"
|
||||
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
||||
.\"
|
||||
.Dd April 30, 1999
|
||||
.Dd September 6, 2003
|
||||
.Dt MODLOAD 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -40,7 +40,7 @@
|
||||
.Nd load a kernel module
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl dnvsS
|
||||
.Op Fl dfnsSv
|
||||
.Op Fl A Ar kernel
|
||||
.Op Fl e Ar entry
|
||||
.Op Fl p Ar postinstall
|
||||
@ -62,6 +62,14 @@ Debug.
|
||||
Used to debug
|
||||
.Nm
|
||||
itself.
|
||||
.It Fl f
|
||||
This forces load of the module, even if it doesn't match currently
|
||||
running kernel. When LKM is loaded, kernel normally checks if the LKM
|
||||
is compatible with the running kernel. This option disables this check.
|
||||
.Em Note
|
||||
incompatible LKM can cause system instability, including data loss
|
||||
or corruption. Don't use this option unless you are sure what you
|
||||
are doing.
|
||||
.It Fl n
|
||||
Do everything, except calling the module entry point (and any
|
||||
post-install program).
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: modload.c,v 1.40 2003/07/13 07:45:27 itojun Exp $ */
|
||||
/* $NetBSD: modload.c,v 1.41 2003/09/06 19:23:20 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: modload.c,v 1.40 2003/07/13 07:45:27 itojun Exp $");
|
||||
__RCSID("$NetBSD: modload.c,v 1.41 2003/09/06 19:23:20 jdolecek Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -69,6 +69,7 @@ __RCSID("$NetBSD: modload.c,v 1.40 2003/07/13 07:45:27 itojun Exp $");
|
||||
|
||||
int debug = 0;
|
||||
int verbose = 0;
|
||||
u_long force = 0;
|
||||
char *out = NULL;
|
||||
int symtab = 0;
|
||||
int Sflag;
|
||||
@ -121,7 +122,7 @@ usage(void)
|
||||
{
|
||||
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, "modload [-d] [-v] [-n] [-s] [-S] "
|
||||
fprintf(stderr, "modload [-dfnsSv] "
|
||||
"[-A <kernel>] [-e <entry>]\n");
|
||||
fprintf(stderr,
|
||||
" [-p <postinstall>] [-o <output file>] <input file>\n");
|
||||
@ -257,11 +258,14 @@ main(int argc, char **argv)
|
||||
void *modentry; /* XXX */
|
||||
int noready = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "dnvse:p:o:A:ST:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "dfnvse:p:o:A:ST:")) != -1) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break; /* debug */
|
||||
case 'f':
|
||||
force = 1;
|
||||
break; /* force load */
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break; /* verbose */
|
||||
@ -440,6 +444,14 @@ main(int argc, char **argv)
|
||||
|
||||
fileopen |= PART_RESRV;
|
||||
|
||||
if (force) {
|
||||
if (ioctl(devfd, LMFORCE, &force) == -1)
|
||||
err(10, "can't force load");
|
||||
|
||||
warnx("Forced load of LKM '%s'. MAY CAUSE SYSTEM INSTABILITY.",
|
||||
modout);
|
||||
}
|
||||
|
||||
/*
|
||||
* Relink at kernel load address
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user