modinfo: don't parse built-in for explicitly given module files
PATCH 1/1 modinfo: don't parse built-in for explicitly given module files
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.
--- libkmod/libkmod-module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libkmod/libkmod-module.c +2 -1
@@ -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);
Signature · 1 line
2.26.2
Quoted 9 lines · Takashi Iwai
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.
Quoted 6 lines
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")Signed-off-by Takashi Iwai <[email protected]>
LGTM
Thanks
Quoted 21 lines
--- libkmod/libkmod-module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)libkmod/libkmod-module.c +2
-1@@ -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);Signature · 1 line
2.26.2
Quoted 25 lines · Takashi Iwai
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")Signed-off-by Takashi Iwai <[email protected]>--- libkmod/libkmod-module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)libkmod/libkmod-module.c +0
-0
libkmod/libkmod-module.c KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_ · line 2296
Quoted 6 lines
libkmod/libkmod-module.c +2
-1@@ -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
Quoted 6 lines
libkmod/libkmod-module.c +0
-1count =kmod_builtin_get_modinfo (mod->ctx,kmod_module_get_name (mod), &strings); --2.26.2
PATCH 1/1 libkmod: Set builtin to no when module is created from path.
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.
--- libkmod/libkmod-module.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
libkmod/libkmod-module.c +9 -9
@@ -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 ; }
Signature · 1 line
2.31.1
Re: [PATCH] libkmod: Set builtin to no when module is created from path.
Quoted 2 lines · Michal Suchanek
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
Quoted 60 lines
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/ open hereSuggested-by Lucas De Marchi <[email protected]>Signed-off-by Michal Suchanek <[email protected]>--- libkmod/libkmod-module.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)libkmod/libkmod-module.c +9
-10@@ -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
PATCH v2 1/1 libkmod: Set builtin to no when module is created from path.
In reply to Michal SuchanekFrom: Michal Suchanek <[email protected]>
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.
--- libkmod/libkmod-module.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
libkmod/libkmod-module.c +9 -8
@@ -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 ;
Signature · 1 line
2.31.1
PATCH 1/1 libkmod: Set builtin to no when module is created from path.
From: Michal Suchanek <[email protected]>
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.
--- libkmod/libkmod-module.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
libkmod/libkmod-module.c +9 -8
@@ -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 ;
Signature · 1 line
2.31.1
Re: [PATCH v2] libkmod: Set builtin to no when module is created from path.
In reply to Lucas De Marchi