Skip to content

libkmod: honor install commands on modules with softdeps - #461

Open
prabhakarpujeri wants to merge 1 commit into
kmod-project:masterfrom
prabhakarpujeri:fix-install-cmd-softdep
Open

prabhakarpujeri wants to merge 1 commit into
kmod-project:masterfrom
prabhakarpujeri:fix-install-cmd-softdep

Conversation

@prabhakarpujeri

Copy link
Copy Markdown

Fixes #446.

Since 89e9248 ("modprobe: obey blacklist and softdep pre"), __kmod_module_fill_softdep() marks every module that has any softdep entry with ignorecmd, and kmod_module_probe_insert_module() then silently skips the module's configured install command and falls back to insmod.

Consequence: the documented block formula

blacklist ksmbd
install ksmbd /bin/false

has no effect for a module that ships a softdep (Gentoo confirmed blacklist+install is silently ignored) – a dry run inserts the real module file, and as the reporter notes, "even something as simple as a softdep kills any install command".

Changes

  • libkmod: only set ignorecmd when no install command is configured (kmod_module_get_install_commands(mod) == NULL). An explicit install directive is user configuration and must win over softdep metadata; modules without one keep the existing behavior, and --ignore-install is unaffected.
  • testsuite: new fixture test-modprobe/install-cmd-softdep – module with a pre softdep plus install mod-foo /bin/true. The dry run must print insmod …/mod-foo-a.ko followed by install /bin/true; without the fix it prints insmod …/mod-foo.ko instead. Verified red on master, green with this change; full testsuite passes.

Reproduction (on master)

# fake rootfs: mod-foo.ko + mod-foo-a.ko,
# modules.softdep: softdep mod-foo pre: mod-foo-a
# /run modprobe.d: blacklist mod-foo / install mod-foo /bin/false
$ modprobe -n -v mod-foo
insmod <rootfs>/lib/modules/$(uname -r)/kernel/mod-foo-a.ko
insmod <rootfs>/lib/modules/$(uname -r)/kernel/mod-foo.ko   ← installs despite /bin/false

after this change, the second line is install /bin/false.

__kmod_module_fill_softdep() marks any module that has softdep entries with ignorecmd, and kmod_module_probe_insert_module() then skips the module's install command and falls back to a plain insmod.  An explicit 'install <mod> <cmd>' stanza is silently dropped as soon as the module ships any softdep: blacklisting such a module with the documented

    blacklist ksmbd
    install ksmbd /bin/false

combination has no effect, and a dry run shows an insmod of the real
module file.

An 'install' directive is user configuration and must win over softdep
metadata.  Only ignore the command when no install command is
configured, so the softdep path keeps its current behavior for modules
without one.

Add a test-modprobe fixture covering it: a module with a softdep and an
install command must run the install command in a dry run (the pre
softdep is still inserted first) instead of insmod-ing the module
itself.

Link: kmod-project#446
Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't blacklist ksmbd, even with install /bin/false

1 participant