diff mbox series

libkmod: Set builtin to no when module is created from path.

Message ID 20210818205159.6066-1-msuchanek@suse.de (mailing list archive)
State New
Headers show
Series libkmod: Set builtin to no when module is created from path. | expand

Commit Message

Michal Suchánek Aug. 18, 2021, 8:52 p.m. UTC
Something like this?

Thanks

Michal

--------------------------------------------------------------------

A recent bug report showed that modinfo doesn't give the signature
information for certain modules, and it turned out to happen only on
the modules that are built-in on the running kernel; then modinfo
skips the signature check, as if the target module file never exists.
The behavior is, however, inconsistent when modinfo is performed for
external modules (no matter which kernel version is) and the module
file path is explicitly given by a command-line argument, which
guarantees the presence of the module file itself.

Fixes: e7e2cb61fa9f ("modinfo: Show information about built-in modules")
Link: https://lore.kernel.org/linux-modules/CAKi4VAJVvY3=JdSZm-GD1hJqyCPYaYz-jBJ_REeY5BakVb6_ww@mail.gmail.com/
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189537
Suggested-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 libkmod/libkmod-module.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Lucas De Marchi Aug. 18, 2021, 9:23 p.m. UTC | #1
On Wed, Aug 18, 2021 at 1:53 PM Michal Suchanek <msuchanek@suse.de> wrote:
>
> Something like this?

yep. Just a matter of style but I think I like the *mod = m as the
last thing. Let me send it with that additional change.

thanks
Lucas De Marchi

>
> Thanks
>
> Michal
>
> --------------------------------------------------------------------
>
> A recent bug report showed that modinfo doesn't give the signature
> information for certain modules, and it turned out to happen only on
> the modules that are built-in on the running kernel; then modinfo
> skips the signature check, as if the target module file never exists.
> The behavior is, however, inconsistent when modinfo is performed for
> external modules (no matter which kernel version is) and the module
> file path is explicitly given by a command-line argument, which
> guarantees the presence of the module file itself.
>
> Fixes: e7e2cb61fa9f ("modinfo: Show information about built-in modules")
> Link: https://lore.kernel.org/linux-modules/CAKi4VAJVvY3=JdSZm-GD1hJqyCPYaYz-jBJ_REeY5BakVb6_ww@mail.gmail.com/
> BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189537
> Suggested-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  libkmod/libkmod-module.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
> index 9e878a5345a1..53b220d492e8 100644
> --- a/libkmod/libkmod-module.c
> +++ b/libkmod/libkmod-module.c
> @@ -432,18 +432,18 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
>                 }
>
>                 *mod = kmod_module_ref(m);
> -               return 0;
> -       }
> +       } else {
> +               err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m);
> +               if (err < 0) {
> +                       free(abspath);
> +                       return err;
> +               }
>
> -       err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m);
> -       if (err < 0) {
> -               free(abspath);
> -               return err;
> +               m->path = abspath;
> +               *mod = m;
>         }
>
> -       m->path = abspath;
> -       *mod = m;
> -
> +       (*mod)->builtin = KMOD_MODULE_BUILTIN_NO;
>         return 0;
>  }
>
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 9e878a5345a1..53b220d492e8 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -432,18 +432,18 @@  KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
 		}
 
 		*mod = kmod_module_ref(m);
-		return 0;
-	}
+	} else {
+		err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m);
+		if (err < 0) {
+			free(abspath);
+			return err;
+		}
 
-	err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m);
-	if (err < 0) {
-		free(abspath);
-		return err;
+		m->path = abspath;
+		*mod = m;
 	}
 
-	m->path = abspath;
-	*mod = m;
-
+	(*mod)->builtin = KMOD_MODULE_BUILTIN_NO;
 	return 0;
 }