[Bug 277967] The loader should fail gracefully when /boot/loader.conf attempts to load a module that is too large

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 28 Mar 2024 13:41:11 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277967

Tomoaki AOKI <junchoon@dec.sakura.ne.jp> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |junchoon@dec.sakura.ne.jp

--- Comment #1 from Tomoaki AOKI <junchoon@dec.sakura.ne.jp> ---
This needs considerations for modules which depends on other modules.

Possibly, the first module could be loaded fine, but exceeds the limit when
attempting to load its dependencies, and at worse, the first module cannot be
unloaded safely.
So multiple (at least 2) passes would be needed to actually load modules.

For example, nvidia-drm.ko depends on nvidia-modeset.ko, nvidia.ko and drm.ko
(possibly more implicit).

Possible option would be to include module sizes in linker.hints files.
And looking output of kldstat, dependencies seems to be loaded after at least
one of its consumers.

To avoid this,
 1. read /boot/loader.conf[.local] thoroughly to determine
    all modules specified to load,

 2. read linker.hints in all module directories to determine
    dependencies,

 3. at the same time of 2., fetch sizes of modules to be loaded,

 4. decide the loading order, basically the order appears
    in /boot/loader.conf[.local], but dependencies should be
    loaded before their first consumers,

 5. finally decide to which to be loaded (which to ignore) and
    actually load modules.

But at the same time, considerations would be needed for the cases linker.hints
are somehow not up-to-date or nonexistent.
This could happen when admins just copies pre-built modules but fotgot to run
kldxref, or kldxref somehow failed to run (crash?).

Anyway, would be complicated.

-- 
You are receiving this mail because:
You are the assignee for the bug.