linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] modinfo: don't parse built-in for explicitly given module files
@ 2021-08-18 11:22 Takashi Iwai
  2021-08-18 11:41 ` Michal Suchánek
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Takashi Iwai @ 2021-08-18 11:22 UTC (permalink / raw)
  To: linux-modules; +Cc: Michal Suchánek

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.

This patch addresses the regression by checking the presence of the
module path at first before checking the built-in module.

Fixes: e7e2cb61fa9f ("modinfo: Show information about built-in modules")
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189537
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 libkmod/libkmod-module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 6e0ff1a99604..9e878a5345a1 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2292,7 +2292,8 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
 	assert(*list == NULL);
 
 	/* remove const: this can only change internal state */
-	if (kmod_module_is_builtin((struct kmod_module *)mod)) {
+	if (!kmod_module_get_path(mod) &&
+	    kmod_module_is_builtin((struct kmod_module *)mod)) {
 		count = kmod_builtin_get_modinfo(mod->ctx,
 						kmod_module_get_name(mod),
 						&strings);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] modinfo: don't parse built-in for explicitly given module files
  2021-08-18 11:22 [PATCH] modinfo: don't parse built-in for explicitly given module files Takashi Iwai
@ 2021-08-18 11:41 ` Michal Suchánek
  2021-08-18 12:05 ` Petr Vorel
  2021-08-18 19:13 ` Lucas De Marchi
  2 siblings, 0 replies; 9+ messages in thread
From: Michal Suchánek @ 2021-08-18 11:41 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: linux-modules

On Wed, Aug 18, 2021 at 01:22:03PM +0200, Takashi Iwai wrote:
> 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.
> 
> This patch addresses the regression by checking the presence of the
> module path at first before checking the built-in module.
> 
> Fixes: e7e2cb61fa9f ("modinfo: Show information about built-in modules")
> BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189537
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Reviewed-by: Michal Suchánek <msuchanek@suse.de>

LGTM

Thanks
> ---
>  libkmod/libkmod-module.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
> index 6e0ff1a99604..9e878a5345a1 100644
> --- a/libkmod/libkmod-module.c
> +++ b/libkmod/libkmod-module.c
> @@ -2292,7 +2292,8 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
>  	assert(*list == NULL);
>  
>  	/* remove const: this can only change internal state */
> -	if (kmod_module_is_builtin((struct kmod_module *)mod)) {
> +	if (!kmod_module_get_path(mod) &&
> +	    kmod_module_is_builtin((struct kmod_module *)mod)) {
>  		count = kmod_builtin_get_modinfo(mod->ctx,
>  						kmod_module_get_name(mod),
>  						&strings);
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] modinfo: don't parse built-in for explicitly given module files
  2021-08-18 11:22 [PATCH] modinfo: don't parse built-in for explicitly given module files Takashi Iwai
  2021-08-18 11:41 ` Michal Suchánek
@ 2021-08-18 12:05 ` Petr Vorel
  2021-08-18 19:13 ` Lucas De Marchi
  2 siblings, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2021-08-18 12:05 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: linux-modules, Michal Suchánek

Hi,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] modinfo: don't parse built-in for explicitly given module files
  2021-08-18 11:22 [PATCH] modinfo: don't parse built-in for explicitly given module files Takashi Iwai
  2021-08-18 11:41 ` Michal Suchánek
  2021-08-18 12:05 ` Petr Vorel
@ 2021-08-18 19:13 ` Lucas De Marchi
  2021-08-18 20:52   ` [PATCH] libkmod: Set builtin to no when module is created from path Michal Suchanek
  2 siblings, 1 reply; 9+ messages in thread
From: Lucas De Marchi @ 2021-08-18 19:13 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: linux-modules, Michal Suchánek

On Wed, Aug 18, 2021 at 4:23 AM Takashi Iwai <tiwai@suse.de> wrote:
>
> 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.
>
> This patch addresses the regression by checking the presence of the
> module path at first before checking the built-in module.
>
> Fixes: e7e2cb61fa9f ("modinfo: Show information about built-in modules")
> BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189537
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  libkmod/libkmod-module.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
> index 6e0ff1a99604..9e878a5345a1 100644
> --- a/libkmod/libkmod-module.c
> +++ b/libkmod/libkmod-module.c
> @@ -2292,7 +2292,8 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
>         assert(*list == NULL);
>
>         /* remove const: this can only change internal state */
> -       if (kmod_module_is_builtin((struct kmod_module *)mod)) {
> +       if (!kmod_module_get_path(mod) &&
> +           kmod_module_is_builtin((struct kmod_module *)mod)) {

thanks for spotting this... but I'm not sure this is the right fix.
kmod_module_is_builtin() shouldn't return true if the module was
created by path rather than lookup. It seems we should rather set
mod->builtin = KMOD_MODULE_BUILTIN_NO in
kmod_module_new_from_path(). This would also fix the use of
kmod_module_is_builtin() directly by applications.

Since the builtin check uses lazy initialization,  the default is
KMOD_MODULE_BUILTIN_UNKNOWN, hence the bug here.

Lucas De Marchi

>                 count = kmod_builtin_get_modinfo(mod->ctx,
>                                                 kmod_module_get_name(mod),
>                                                 &strings);
> --
> 2.26.2
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] libkmod: Set builtin to no when module is created from path.
  2021-08-18 19:13 ` Lucas De Marchi
@ 2021-08-18 20:52   ` Michal Suchanek
  2021-08-18 21:23     ` Lucas De Marchi
  2021-08-18 21:24     ` [PATCH v2] " Lucas De Marchi
  0 siblings, 2 replies; 9+ messages in thread
From: Michal Suchanek @ 2021-08-18 20:52 UTC (permalink / raw)
  To: Lucas De Marchi, linux-modules; +Cc: Michal Suchanek, Takashi Iwai, Petr Vorel

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(-)

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libkmod: Set builtin to no when module is created from path.
  2021-08-18 20:52   ` [PATCH] libkmod: Set builtin to no when module is created from path Michal Suchanek
@ 2021-08-18 21:23     ` Lucas De Marchi
  2021-08-18 21:24     ` [PATCH v2] " Lucas De Marchi
  1 sibling, 0 replies; 9+ messages in thread
From: Lucas De Marchi @ 2021-08-18 21:23 UTC (permalink / raw)
  To: Michal Suchanek; +Cc: linux-modules, Takashi Iwai, Petr Vorel

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
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] libkmod: Set builtin to no when module is created from path.
  2021-08-18 20:52   ` [PATCH] libkmod: Set builtin to no when module is created from path Michal Suchanek
  2021-08-18 21:23     ` Lucas De Marchi
@ 2021-08-18 21:24     ` Lucas De Marchi
  2021-08-18 21:24       ` [PATCH] " Lucas De Marchi
  2021-08-19 15:28       ` [PATCH v2] " Petr Vorel
  1 sibling, 2 replies; 9+ messages in thread
From: Lucas De Marchi @ 2021-08-18 21:24 UTC (permalink / raw)
  To: linux-modules; +Cc: Michal Suchanek, Takashi Iwai, Petr Vorel, Lucas De Marchi

From: Michal Suchanek <msuchanek@suse.de>

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 | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 6e0ff1a..6f7747c 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -431,17 +431,18 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
 			return -EEXIST;
 		}
 
-		*mod = kmod_module_ref(m);
-		return 0;
-	}
+		kmod_module_ref(m);
+	} 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;
 	}
 
-	m->path = abspath;
+	m->builtin = KMOD_MODULE_BUILTIN_NO;
 	*mod = m;
 
 	return 0;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] libkmod: Set builtin to no when module is created from path.
  2021-08-18 21:24     ` [PATCH v2] " Lucas De Marchi
@ 2021-08-18 21:24       ` Lucas De Marchi
  2021-08-19 15:28       ` [PATCH v2] " Petr Vorel
  1 sibling, 0 replies; 9+ messages in thread
From: Lucas De Marchi @ 2021-08-18 21:24 UTC (permalink / raw)
  To: linux-modules; +Cc: Michal Suchanek, Takashi Iwai, Petr Vorel, Lucas De Marchi

From: Michal Suchanek <msuchanek@suse.de>

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 | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 6e0ff1a..6f7747c 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -431,17 +431,18 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
 			return -EEXIST;
 		}
 
-		*mod = kmod_module_ref(m);
-		return 0;
-	}
+		kmod_module_ref(m);
+	} 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;
 	}
 
-	m->path = abspath;
+	m->builtin = KMOD_MODULE_BUILTIN_NO;
 	*mod = m;
 
 	return 0;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] libkmod: Set builtin to no when module is created from path.
  2021-08-18 21:24     ` [PATCH v2] " Lucas De Marchi
  2021-08-18 21:24       ` [PATCH] " Lucas De Marchi
@ 2021-08-19 15:28       ` Petr Vorel
  1 sibling, 0 replies; 9+ messages in thread
From: Petr Vorel @ 2021-08-19 15:28 UTC (permalink / raw)
  To: Lucas De Marchi
  Cc: linux-modules, Michal Suchanek, Takashi Iwai, Lucas De Marchi

Hi all,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-08-19 15:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 11:22 [PATCH] modinfo: don't parse built-in for explicitly given module files Takashi Iwai
2021-08-18 11:41 ` Michal Suchánek
2021-08-18 12:05 ` Petr Vorel
2021-08-18 19:13 ` Lucas De Marchi
2021-08-18 20:52   ` [PATCH] libkmod: Set builtin to no when module is created from path Michal Suchanek
2021-08-18 21:23     ` Lucas De Marchi
2021-08-18 21:24     ` [PATCH v2] " Lucas De Marchi
2021-08-18 21:24       ` [PATCH] " Lucas De Marchi
2021-08-19 15:28       ` [PATCH v2] " Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).