Commit Graph

71 Commits

Author SHA1 Message Date
pgoyette bf43b300a1 Keep condvar wmesg within 8 char limit 2010-08-11 12:04:49 +00:00
pgoyette 224f73d8d9 1. Add an allocator for 'struct module *' and use it instead of local
allocations.

2. Add a new member mod_flags to the 'struct module *' and define
   MODFLG_MUST_FORCE.  If this flag is set and the entry is on the list
   of builtins, it means that the module has been explicitly unloaded
   and any re-loads will require the MODCTL_LOAD_FORCE flag. Provide a
   module_require_force() method to set this flag;  once set, it should
   never be unset.

3. Rename original module_init2() to module_start_unload_thread() to be
   more descriptive of what it does.

4. Add a new module_builtin_require_force() routine that sets the
   MODFLG_MUST_FORCE flag for any module that has not yet successfully
   been initialized.  Call it after module_init_class(MODULE_CLASS_ANY)
   to disable remaining built-in modules.

This makes built-in versions of the xxxVERBOSE modules work once more,
resolving breakage reported by jruoho@ and njoly@.

Discussed on tech-kern, and comments and suggestions implemented.  No
additional discussion for last week.  Tested only on amd64 systems, but
there's nothing here that should be port- or architecture-specific (no
more specific than existing module implementation) so others should not
break.
2010-06-26 07:23:57 +00:00
pooka f0c67b0751 Feed dust to a few linkset uses and explicitly call the constructor. 2010-05-26 23:53:21 +00:00
pgoyette c77c96962b Move definition of module_load_vfs_vec from kern_module_vfs.c to
kern_module.c - keeps rump happy.

Thanks, pooka!
2010-05-24 16:37:17 +00:00
pgoyette c269eb06dd Clean up kern_module.c rev 1.66, thanks to pooka@ for review & suggestions 2010-05-24 15:34:48 +00:00
pgoyette 2c4465aaa0 Protect against attempting to load modules from the filesystem until we
have mounted the root file-system.  This allows us to load built-in and
boot-loader-provided modules much earlier during startup.
2010-05-24 03:50:25 +00:00
pooka 193bcc771a If a builtin dependency is missing, error instead of panic. As
pointed out by martin, configurations like builtin nfsserver can
be succesfully linked without including all dependencies (specifically,
nfs).  Until all such weirdosities are fixed, opt for at least a
semifunctional system.
2010-05-02 11:01:03 +00:00
jruoho 1cbdcd8dc6 Use CTLTYPE_BOOL. 2010-04-19 11:20:56 +00:00
pooka d8c5395931 Don't loop eternal if init of a builtin module fails. 2010-04-16 11:51:23 +00:00
pooka 1c55854229 Print builtin "use -f" message only if not autoloading. Otherwise
it'll get spammy.

XXX: this should probably be printed iff the toplevel module is
not being autoloaded (i.e. there is a human to interpret the error).
Otherwise disabled dependencies give a misleading EPERM.
2010-03-18 18:25:45 +00:00
pooka d76b630321 Never autounload builtin modules (they will never be autoloaded if disabled). 2010-03-18 17:33:18 +00:00
pooka effc302a58 Make module_{lookup,enqueue}() static now that it's possible again
(effectively reverts my kern_module rev. 1.53 from some months ago)
2010-03-05 20:10:05 +00:00
pooka ee7bfacd73 Move builtin modules to a list in init and load them from there
instead of using linksets directly.  This has two implications:

1) It is now possible to "unload" a builtin module provided it is
   not busy.  This is useful e.g. to disable a kernel feature as
   an immediate workaround to a security problem.  To re-initialize
   the module, modload -f <name> is required.
2) It is possible to use builtin modules which were linked at
   runtime with an external linker (dlopen + rump).
2010-03-05 18:35:01 +00:00
pooka 7363f77230 Replace unsafe use of TAILQ_FOREACH: as the comment says, the
structures are pulled off the list in the loop and it's anyone's
guess where they go after that.
2010-03-03 17:58:36 +00:00
pooka 27d8901688 Update comment: unloaded modules which were pumped up by the
bootloader are not freed at the end of bootstrap (there should be
none, although this is not asserted.  maybe it should be?).
2010-01-19 15:23:14 +00:00
dholland a4ce70f1ad typo in comment 2010-01-01 03:22:13 +00:00
elad 4046eb056d Move the listener plugging to module_init(), as it runs after kauth_init()
now. (Leaving only the module kthread creation in module_init2().)
2009-12-29 17:49:21 +00:00
pooka a8ed404de6 * make it possible to include kern_module in a kernel without vfs
support, i.e. move vfs functionality to a separate module
  (kern_module_vfs.c)
* make module proplist size an MI constant (now 8k) instead of PAGE_SIZE
* change some error values to something else than the karmic EINVAL
2009-11-18 17:40:45 +00:00
pooka 35a75982e4 expose module_{lookup,enqueue}() 2009-11-05 14:09:14 +00:00
jnemeth 30d0592bd3 allow passing a NULL proplib dictionary to modctl(MODCTL_LOAD, ...) 2009-10-16 00:27:07 +00:00
elad abc7a4290b Put module loading policy back in the subsystem.
Revisit: consider moving kauth_init() above module_init() in main().
2009-10-03 00:06:37 +00:00
elad 53ca19a3b3 First part of secmodel cleanup and other misc. changes:
- Separate the suser part of the bsd44 secmodel into its own secmodel
    and directory, pending even more cleanups. For revision history
    purposes, the original location of the files was

        src/sys/secmodel/bsd44/secmodel_bsd44_suser.c
        src/sys/secmodel/bsd44/suser.h

  - Add a man-page for secmodel_suser(9) and update the one for
    secmodel_bsd44(9).

  - Add a "secmodel" module class and use it. Userland program and
    documentation updated.

  - Manage secmodel count (nsecmodels) through the module framework.
    This eliminates the need for secmodel_{,de}register() calls in
    secmodel code.

  - Prepare for secmodel modularization by adding relevant module bits.
    The secmodels don't allow auto unload. The bsd44 secmodel depends
    on the suser and securelevel secmodels. The overlay secmodel depends
    on the bsd44 secmodel. As the module class is only cosmetic, and to
    prevent ambiguity, the bsd44 and overlay secmodels are prefixed with
    "secmodel_".

  - Adapt the overlay secmodel to recent changes (mainly vnode scope).

  - Stop using link-sets for the sysctl node(s) creation.

  - Keep sysctl variables under nodes of their relevant secmodels. In
    other words, don't create duplicates for the suser/securelevel
    secmodels under the bsd44 secmodel, as the latter is merely used
    for "grouping".

  - For the suser and securelevel secmodels, "advertise presence" in
    relevant sysctl nodes (sysctl.security.models.{suser,securelevel}).

  - Get rid of the LKM preprocessor stuff.

  - As secmodels are now modules, there's no need for an explicit call
    to secmodel_start(); it's handled by the module framework. That
    said, the module framework was adjusted to properly load secmodels
    early during system startup.

  - Adapt rump to changes: Instead of using empty stubs for securelevel,
    simply use the suser secmodel. Also replace secmodel_start() with a
    call to secmodel_suser_start().

  - 5.99.20.

Testing was done on i386 ("release" build). Spearated module_init()
changes were tested on sparc and sparc64 as well by martin@ (thanks!).

Mailing list reference:

	http://mail-index.netbsd.org/tech-kern/2009/09/25/msg006135.html
2009-10-02 18:50:12 +00:00
dyoung 61fa5bb9be Make kobj_stat() return ENOSYS instead of panicking ("not modular")
on non-MODULAR kernels.  Make a few kobj_stat() callers check for
a non-zero return code and deal gracefully.
2009-06-17 21:04:25 +00:00
jnemeth cbd3656645 Add the MODCTL_NO_PROP flag to tell the kernel to ignore <module>.prop.
Add the '-P' option to modload(8) to set this flag.
2009-06-09 20:35:02 +00:00
jnemeth 32b670979a Add code to merge the modload "command line" with <module>.prop. 2009-06-09 19:09:03 +00:00
jnemeth 1bdbe18dce Read in a <module>.prop file if it exists and internalize then pass it
to the <module> being loaded.

XXX A <module>.prop file will override anything on the "command line".
This will be fixed in the next commit.
2009-06-07 09:47:31 +00:00
jnemeth d73b80a12b Move all namei flags handling into kobj_load_file().
When I originally wrote this, I was going for maximum flexibility.
However, after a private discussion with dholland@, I see how this
will cause problems with the future world order of namei whenever
that might be.  At the moment, I don't need the extra flexibility,
but if something comes up this may have to be revisited.
2009-05-26 08:34:22 +00:00
jnemeth a15ece476a Phase 0.5 of my options MODULAR enhancements. As suggested by ad@,
these commits move all path handling into module_do_load() from
kobj_load_file().  This way the final path used to load a module
is available for loading <module>.plist, which will store parameters
for a module.  The end goal of this project is good support for
MODULAR device drivers.
2009-05-25 22:33:00 +00:00
ad 27695c89cb ddb: don't try to stat builtin modules. 2009-05-24 14:54:17 +00:00
apb 0cc72e51ac Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
2009-02-13 22:41:00 +00:00
rmind 6d73ddd355 Revert path of modules back to "/stand". 2009-01-24 22:14:44 +00:00
rmind f0e51651e4 Change path to kernel modules from "/stand" to "/kernel".
Needs to go in before 5.0.  Proposed on <tech-kern>.
2009-01-24 00:29:12 +00:00
drochner dc83650fb8 add __gcc__ __format__ __string__ __attributes__ to catch mistakes early 2009-01-20 20:12:41 +00:00
christos 55d90fae57 - Don't autounload modules loaded during boot. In my case, ffs got unloaded
because my cdrom takes too long to initialize.
- Consistently print error messages in all error cases.
2008-12-28 03:21:02 +00:00
ad 8ff4eb83a8 Back out revision 1.35 which is no longer necessary and causes the system
to try autounloading modules perpetually.
2008-12-05 12:55:09 +00:00
ad 6efc20038a PR kern/40110: null, overlay and umap modules loading -> panic (layerfs symbols not there) 2008-12-05 12:51:17 +00:00
christos 579a92f63b PR/40097: bouyer@antioche.lip6.fr: MODULAR tries to unload non-module subsystems
Don't try to unload built-in modules, and if a module is busy don't retry
immediately.
2008-12-03 15:15:01 +00:00
ad 11701b3bf7 Add a couple of sysctls:
kern.module.autoload = 1
kern.module.verbose = 0
2008-12-03 12:14:11 +00:00
ad 6cddbf0ca5 Correct error messages added in revision 1.32. In part from drochner@. 2008-12-03 11:23:15 +00:00
christos 78d77f514f better error messages, and more messages for DIAGNOSTIC. 2008-11-27 21:36:51 +00:00
ad a5a0d68555 Print the size as decimal. 2008-11-25 15:15:28 +00:00
ad 31afc5b6d8 Add some basic DDB stuff for modules. 2008-11-25 15:14:07 +00:00
ad 950585e9b4 module_autoload: disallow path seperators and magic symlinks. 2008-11-19 13:07:42 +00:00
ad 2bae5b390e Some modules may want to avoid autounload because their use is transient.
Their FINI routine may legitimately succeed even though the module is likely
to be used soon again, for example: exec_script. Add a MODULE_CMD_AUTOUNLOAD
to query whether a module wants to avoid autounload.
2008-11-18 11:56:09 +00:00
ad f94a8f9142 - Put modules that depend on others at the head of the queue so autounload
can unload requisite modules with only one pass.

- If loading a requisite module, scan the global queue before checking the
  file system to see if it exists.  If it's already present we don't care.
2008-11-18 11:39:41 +00:00
ad 79d9beffc8 - If the system encounters a severe memory shortage, start unloading
unused kernel modules.
- Try to unload any autoloaded kernel modules 10 seconds after their
  load was successful.
- Keep a counter to track module load/unload events.
2008-11-14 23:06:45 +00:00
ad 0efea177e3 Remove LKMs and switch to the module framework, pass 1.
Proposed on tech-kern@.
2008-11-12 12:35:50 +00:00
ad 52e9644b6b Make MODCTL_LOAD_FORCE do something. 2008-10-22 11:19:15 +00:00
ad 7b228b5a9c - Be clear about whether module load is explicit or system initiated (auto).
- Require that module_lock is held to autoload, so that any preconditions
  can be safely checked.
2008-10-22 11:16:29 +00:00
pooka b629cd421b expose module_compatible() 2008-08-01 14:05:15 +00:00