[PATCH v1] modprobe: Add support for modprobe.blacklist=module1, module2, ...

Denys Vlasenko vda.linux at googlemail.com
Mon Dec 21 20:19:07 UTC 2020


On Tue, Nov 3, 2020 at 4:31 PM Andy Shevchenko
<andriy.shevchenko at linux.intel.com> wrote:
>
> Add support for modprobe.blacklist=module1,module2,...
>
> On x86_64 (Debian Unstable) it gives +79 bytes.
>
> function                                             old     new   delta
> parse_and_add_kcmdline_module_options                  -     212    +212
> modprobe_main                                        816     932    +116
> do_modprobe                                          743     494    -249
> ------------------------------------------------------------------------------
> (add/remove: 1/0 grow/shrink: 1/1 up/down: 328/-249)           Total: 79 bytes
>
> On i586 with uClibc (Buildroot 2020.05.3) it gives +68 bytes
> add/remove: 1/0 grow/shrink: 1/1 up/down: 262/-194 (68)
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
> ---
>  modutils/modprobe.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/modutils/modprobe.c b/modutils/modprobe.c
> index eeeff7609b36..18a501a151df 100644
> --- a/modutils/modprobe.c
> +++ b/modutils/modprobe.c
> @@ -663,6 +663,25 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
>                 load_modules_dep();
>         }
>
> +       /* Handle modprobe.blacklist=module1,module2,... */
> +       if (ENABLE_FEATURE_MODPROBE_BLACKLIST) {
> +               char *fn, *options, *substr;
> +
> +               options = parse_and_add_kcmdline_module_options(NULL, "modprobe");
> +               while ((substr = strsep(&options, " ")) != NULL) {
> +                       fn = is_prefixed_with(substr, "blacklist=");
> +                       if (fn == NULL)
> +                               continue;
> +
> +                       while ((substr = strsep(&fn, ",")) != NULL) {
> +                               /* blacklist <modulename> */
> +                               get_or_add_modentry(substr)->flags |= MODULE_FLAG_BLACKLISTED;
> +                               DBG("blacklist: %s", substr);
> +                       }
> +               }
> +               free(options);

Bug. "options" is NULL (strsep does that).

> +       }
> +
>         rc = 0;
>         while ((me = llist_pop(&G.probes)) != NULL) {
>                 if (me->realnames == NULL) {


Applied. Thank you.


More information about the busybox mailing list