libkmod: Always search modules.builtin if no alias has been found
PATCH 1/1 libkmod: Always search modules.builtin if no alias has been found
Commit 89443220e broke the lookup for builtin modules. modules.builtin was no longer searched if kmod_lookup_alias_from_kernel_builtin_file() returned 0.
---
I do not know if this is the correct thing to do, or if the commit message makes any sense. However, it solves the problem we were seeing. We use fuse, which installs /etc/modules-load.d/fuse.conf to load the fuse kernel module. However, we have fuse built-in. Normally, the following can be seen in the log:
systemd-modules-load[192]: Module 'fuse' is built in
but after commit 89443220e, we instead got:
systemd-modules-load[193]: Failed to find module 'fuse'
//Peter
libkmod/libkmod-module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libkmod/libkmod-module.c +1 -1
@@ -577,7 +577,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,DBG (ctx,"lookup modules.builtin.modinfo %s\n" , alias); err =kmod_lookup_alias_from_kernel_builtin_file (ctx, alias, list); -if (err == -ENOSYS ) { +if (err ==0 || err == -ENOSYS ) {/* Optional index missing, try the old one */ DBG (ctx,"lookup modules.builtin %s\n" , alias); err =kmod_lookup_alias_from_builtin_file (ctx, alias, list);
Quoted 30 lines · Peter Kjellerstedt
Commit
89443220ebroke the lookup for builtin modules. modules.builtin was no longer searched ifkmod_lookup_alias_from_kernel_builtin_file()returned 0.Signed-off-by Peter Kjellerstedt <[email protected]>---
I do not know if this is the correct thing to do, or if the commit message makes any sense. However, it solves the problem we were seeing. We use fuse, which installs
/etc/modules-load.d/fuse.confto load the fuse kernel module. However, we have fuse built-in. Normally, the following can be seen in the log:systemd-modules-load[192]: Module 'fuse' is built in
but after commit
89443220e, we instead got:systemd-modules-load[193]: Failed to find module 'fuse'
//Peter
libkmod/libkmod-module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libkmod/libkmod-module.c +0
-0
libkmod/libkmod-module.c KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, · line 580
Quoted 5 lines
libkmod/libkmod-module.c +1
-1@@ -577,7 +577,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,DBG (ctx,"lookup modules.builtin.modinfo %s\n" , alias); err =kmod_lookup_alias_from_kernel_builtin_file (ctx, alias, list); -if (err == -ENOSYS ) { +if (err ==0 || err == -ENOSYS ) {
So in your case you do have modules.builtin.modinfo, but fuse doesn't show up there. On the other hand it is listed in modules.builtin. Does modules.builtin.info contain anything or is it an empty file?
It seems to me something else is broken: all modules in modules.builtin should be in modules.builtin.modinfo as well. What is the result of the following commands?
grep fuse /lib/modules/$(uname -r)/modules.builtin grep fuse /lib/modules/$(uname -r)/modules.builtin.modinfo
thanks
Lucas De Marchi
Quoted 3 lines
libkmod/libkmod-module.c +0
-0/* Optional index missing, try the old one */ DBG (ctx,"lookup modules.builtin %s\n" , alias); err =kmod_lookup_alias_from_builtin_file (ctx, alias, list);
Quoted 41 lines
-----Original Message-----
From: Lucas De Marchi <[email protected]>
Sent: den 9 maj 2021 07:55
To: Peter Kjellerstedt <[email protected]>
Cc: linux-modules <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: Re: [PATCH] libkmod: Always search modules.builtin if no alias has been foundQuoted 31 lines · Peter Kjellerstedt
Commit
89443220ebroke the lookup for builtin modules. modules.builtin was no longer searched ifkmod_lookup_alias_from_kernel_builtin_file()returned 0.Signed-off-by Peter Kjellerstedt <[email protected]>---
I do not know if this is the correct thing to do, or if the commit message makes any sense. However, it solves the problem we were seeing. We use fuse, which installs
/etc/modules-load.d/fuse.confto load the fuse kernel module. However, we have fuse built-in. Normally, the following can be seen in the log:systemd-modules-load[192]: Module 'fuse' is built in
but after commit
89443220e, we instead got:systemd-modules-load[193]: Failed to find module 'fuse'
//Peter
libkmod/libkmod-module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libkmod/libkmod-module.c +0
-0@@ -577,7 +577,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
Quoted 8 lines
libkmod/libkmod-module.c KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, · line 580
Quoted 4 lines
libkmod/libkmod-module.c +1
-1DBG (ctx,"lookup modules.builtin.modinfo %s\n" , alias); err =kmod_lookup_alias_from_kernel_builtin_file (ctx, alias, list); -if (err == -ENOSYS ) { +if (err ==0 || err == -ENOSYS ) {So in your case you do have modules.builtin.modinfo, but fuse doesn't show up there. On the other hand it is listed in modules.builtin. Does modules.builtin.info contain anything or is it an empty file?
We have neither modules.builtin.modinfo nor modules.builtin.info. A little googling turned out that modules.builtin.modinfo seems to have been introduced in 5.2, but this product uses a 4.19 based kernel.
Quoted 5 lines
It seems to me something else is broken: all modules in modules.builtin should be in modules.builtin.modinfo as well. What is the result of the following commands?
grep fuse /lib/modules/$(uname -r)/modules.builtin
kernel/fs/fuse/fuse.ko
Quoted 1 line
grep fuse /lib/modules/$(uname -r)/modules.builtin.modinfo
grep: /lib/modules/4.19.110-axis8/modules.builtin.modinfo: No such file or directory
This is an embedded product built with our own distribution based on Poky Gatesgarth from the Yocto Project. The rootfs is read-only, including /lib/modules, so any contest there is created when the firmware image is built.
Quoted 6 lines
thanks
Lucas De MarchiQuoted 3 lines
libkmod/libkmod-module.c +0
-0/* Optional index missing, try the old one */ DBG (ctx,"lookup modules.builtin %s\n" , alias); err =kmod_lookup_alias_from_builtin_file (ctx, alias, list);
//Peter
Quoted 51 lines · Peter Kjellerstedt
Quoted 42 lines
-----Original Message-----
From: Lucas De Marchi <[email protected]>
Sent: den 9 maj 2021 07:55
To: Peter Kjellerstedt <[email protected]>
Cc: linux-modules <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: Re: [PATCH] libkmod: Always search modules.builtin if no alias has been foundQuoted 31 lines · Peter Kjellerstedt
Commit
89443220ebroke the lookup for builtin modules. modules.builtin was no longer searched ifkmod_lookup_alias_from_kernel_builtin_file()returned 0.Signed-off-by Peter Kjellerstedt <[email protected]>---
I do not know if this is the correct thing to do, or if the commit message makes any sense. However, it solves the problem we were seeing. We use fuse, which installs
/etc/modules-load.d/fuse.confto load the fuse kernel module. However, we have fuse built-in. Normally, the following can be seen in the log:systemd-modules-load[192]: Module 'fuse' is built in
but after commit
89443220e, we instead got:systemd-modules-load[193]: Failed to find module 'fuse'
//Peter
libkmod/libkmod-module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libkmod/libkmod-module.c +0
-0@@ -577,7 +577,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,Quoted 8 lines
libkmod/libkmod-module.c KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, · line 580
Quoted 4 lines
libkmod/libkmod-module.c +1
-1DBG (ctx,"lookup modules.builtin.modinfo %s\n" , alias); err =kmod_lookup_alias_from_kernel_builtin_file (ctx, alias, list); -if (err == -ENOSYS ) { +if (err ==0 || err == -ENOSYS ) {So in your case you do have modules.builtin.modinfo, but fuse doesn't show up there. On the other hand it is listed in modules.builtin. Does modules.builtin.info contain anything or is it an empty file?
Quoted 3 lines
We have neither modules.builtin.modinfo nor modules.builtin.info. A little googling turned out that modules.builtin.modinfo seems to have been introduced in 5.2, but this product uses a 4.19 based kernel.
ok, now I understood the entire context. So it seems the problem is not that we are
missing the handling for return 0, but rather that kmod_lookup_alias_from_kernel_builtin_file()
is not returning -ENOSYS when it should (index doesn't exist). I thought this was covered, but
obviously I was wrong. I will take a look what's going on.... we should not handle err == 0 the same
way we handle err == -ENOSYS. If the index is missing we want to fallback to the old one, but if
the index is there and we didn't find the module, we should just return an error.
Lucas De Marchi
Quoted 27 lines
Quoted 6 lines
It seems to me something else is broken: all modules in modules.builtin should be in modules.builtin.modinfo as well. What is the result of the following commands?
grep fuse /lib/modules/$(uname -r)/modules.builtin
kernel/fs/fuse/fuse.koQuoted 1 line
grep fuse /lib/modules/$(uname -r)/modules.builtin.modinfo
grep:
/lib/modules/4.19.110-axis8/modules.builtin.modinfo: No such file or directoryThis is an embedded product built with our own distribution based on Poky Gatesgarth from the Yocto Project. The rootfs is read-only, including
/lib/modules, so any contest there is created when the firmware image is built.Quoted 6 lines
thanks
Lucas De MarchiQuoted 3 lines
libkmod/libkmod-module.c +0
-0/* Optional index missing, try the old one */ DBG (ctx,"lookup modules.builtin %s\n" , alias); err =kmod_lookup_alias_from_builtin_file (ctx, alias, list);//Peter
Quoted 58 lines · Lucas De Marchi
Quoted 51 lines · Peter Kjellerstedt
Quoted 42 lines
-----Original Message-----
From: Lucas De Marchi <[email protected]>
Sent: den 9 maj 2021 07:55
To: Peter Kjellerstedt <[email protected]>
Cc: linux-modules <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: Re: [PATCH] libkmod: Always search modules.builtin if no alias has been foundQuoted 31 lines · Peter Kjellerstedt
Commit
89443220ebroke the lookup for builtin modules. modules.builtin was no longer searched ifkmod_lookup_alias_from_kernel_builtin_file()returned 0.Signed-off-by Peter Kjellerstedt <[email protected]>---
I do not know if this is the correct thing to do, or if the commit message makes any sense. However, it solves the problem we were seeing. We use fuse, which installs
/etc/modules-load.d/fuse.confto load the fuse kernel module. However, we have fuse built-in. Normally, the following can be seen in the log:systemd-modules-load[192]: Module 'fuse' is built in
but after commit
89443220e, we instead got:systemd-modules-load[193]: Failed to find module 'fuse'
//Peter
libkmod/libkmod-module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libkmod/libkmod-module.c +0
-0@@ -577,7 +577,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,Quoted 8 lines
libkmod/libkmod-module.c KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, · line 580
Quoted 4 lines
libkmod/libkmod-module.c +1
-1DBG (ctx,"lookup modules.builtin.modinfo %s\n" , alias); err =kmod_lookup_alias_from_kernel_builtin_file (ctx, alias, list); -if (err == -ENOSYS ) { +if (err ==0 || err == -ENOSYS ) {So in your case you do have modules.builtin.modinfo, but fuse doesn't show up there. On the other hand it is listed in modules.builtin. Does modules.builtin.info contain anything or is it an empty file?
Quoted 3 lines
We have neither modules.builtin.modinfo nor modules.builtin.info. A little googling turned out that modules.builtin.modinfo seems to have been introduced in 5.2, but this product uses a 4.19 based kernel.
Quoted 12 lines
ok, now I understood the entire context. So it seems the problem is not that we are
missing the handling for return 0, but rather thatkmod_lookup_alias_from_kernel_builtin_file()
is not returning-ENOSYSwhen it should (index doesn't exist). I thought this was covered, but
obviously I was wrong. I will take a look what's going on.... we should not handle err == 0 the same
way we handle err ==-ENOSYS. If the index is missing we want to fallback to the old one, but if
the index is there and we didn't find the module, we should just return an error.
Ok, I think I see what's happening. If you have a recent kmod with an old kernel,
you have this scenario:
1) modules.builtin.modinfo doesn't exist since kernel didn't create it
2) depmod will write and empty index to modules.builtin.alias.bin when modules.builtin.modinfo
is not present
I have a fix to depmod to stop writing an empty index. I will submit that for review.
thanks
Lucas De Marchi
Quoted 30 lines
Lucas De Marchi
Quoted 27 lines
Quoted 6 lines
It seems to me something else is broken: all modules in modules.builtin should be in modules.builtin.modinfo as well. What is the result of the following commands?
grep fuse /lib/modules/$(uname -r)/modules.builtin
kernel/fs/fuse/fuse.koQuoted 1 line
grep fuse /lib/modules/$(uname -r)/modules.builtin.modinfo
grep:
/lib/modules/4.19.110-axis8/modules.builtin.modinfo: No such file or directoryThis is an embedded product built with our own distribution based on Poky Gatesgarth from the Yocto Project. The rootfs is read-only, including
/lib/modules, so any contest there is created when the firmware image is built.Quoted 6 lines
thanks
Lucas De MarchiQuoted 3 lines
libkmod/libkmod-module.c +0
-0/* Optional index missing, try the old one */ DBG (ctx,"lookup modules.builtin %s\n" , alias); err =kmod_lookup_alias_from_builtin_file (ctx, alias, list);//Peter
Quoted 81 lines
-----Original Message-----
From: Lucas De Marchi <[email protected]>
Sent: den 11 maj 2021 20:02
To: Peter Kjellerstedt <[email protected]>
Cc: linux-modules <[email protected]>
Subject: Re: [PATCH] libkmod: Always search modules.builtin if no alias has been foundQuoted 58 lines · Lucas De Marchi
Quoted 51 lines · Peter Kjellerstedt
Quoted 42 lines
-----Original Message-----
From: Lucas De Marchi <[email protected]>
Sent: den 9 maj 2021 07:55
To: Peter Kjellerstedt <[email protected]>
Cc: linux-modules <[email protected]>; Peter Kjellerstedt <[email protected]>
Subject: Re: [PATCH] libkmod: Always search modules.builtin if no alias has been foundQuoted 31 lines · Peter Kjellerstedt
Commit
89443220ebroke the lookup for builtin modules. modules.builtin was no longer searched ifkmod_lookup_alias_from_kernel_builtin_file()returned 0.Signed-off-by Peter Kjellerstedt <[email protected]>---
I do not know if this is the correct thing to do, or if the commit message makes any sense. However, it solves the problem we were seeing. We use fuse, which installs
/etc/modules-load.d/fuse.confto load the fuse kernel module. However, we have fuse built-in. Normally, the following can be seen in the log:systemd-modules-load[192]: Module 'fuse' is built in
but after commit
89443220e, we instead got:systemd-modules-load[193]: Failed to find module 'fuse'
//Peter
libkmod/libkmod-module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libkmod/libkmod-module.c +0
-0@@ -577,7 +577,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,Quoted 8 lines
libkmod/libkmod-module.c KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, · line 580
Quoted 4 lines
libkmod/libkmod-module.c +1
-1DBG (ctx,"lookup modules.builtin.modinfo %s\n" , alias); err =kmod_lookup_alias_from_kernel_builtin_file (ctx, alias, list); -if (err == -ENOSYS ) { +if (err ==0 || err == -ENOSYS ) {So in your case you do have modules.builtin.modinfo, but fuse doesn't show up there. On the other hand it is listed in modules.builtin. Does modules.builtin.info contain anything or is it an empty file?
Quoted 3 lines
We have neither modules.builtin.modinfo nor modules.builtin.info. A little googling turned out that modules.builtin.modinfo seems to have been introduced in 5.2, but this product uses a 4.19 based kernel.
Quoted 9 lines
ok, now I understood the entire context. So it seems the problem is not that we are missing the handling for return 0, but rather that
kmod_lookup_alias_from_kernel_builtin_file()is not returning-ENOSYSwhen it should (index doesn't exist). I thought this was covered, but obviously I was wrong. I will take a look what's going on.... we should not handle err == 0 the same way we handle err ==-ENOSYS. If the index is missing we want to fallback to the old one, but if the index is there and we didn't find the module, we should just return an error.Ok, I think I see what's happening. If you have a recent kmod with an old kernel, you have this scenario:
Quoted 6 lines
1) modules.builtin.modinfo doesn't exist since kernel didn't create it
2) depmod will write and empty index to modules.builtin.alias.bin when modules.builtin.modinfo is not presentI have a fix to depmod to stop writing an empty index. I will submit that for review.
I have tested the suggested solution and it solves the problem for us. Thank you.
//Peter
Quoted 39 lines
thanks
Lucas De MarchiQuoted 6 lines
Lucas De Marchi
Quoted 3 lines
Quoted 3 lines
It seems to me something else is broken: all modules in modules.builtin should be in modules.builtin.modinfo as well. What
is
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
the result of the following commands?
grep fuse /lib/modules/$(uname -r)/modules.builtin
kernel/fs/fuse/fuse.koQuoted 1 line
grep fuse /lib/modules/$(uname -r)/modules.builtin.modinfo
grep:
/lib/modules/4.19.110-axis8/modules.builtin.modinfo: No suchfile or directory
Quoted 3 lines
Quoted 3 lines
This is an embedded product built with our own distribution based on Poky Gatesgarth from the Yocto Project. The rootfs is read-only,
including
Quoted 1 line
Quoted 1 line
/lib/modules, so any contest there is created when the firmware imageis
Quoted 8 lines
Quoted 8 lines
built.
Quoted 6 lines
thanks
Lucas De MarchiQuoted 3 lines
libkmod/libkmod-module.c +0
-0/* Optional index missing, try the old one */ DBG (ctx,"lookup modules.builtin %s\n" , alias); err = kmod_lookup_alias_from_builtin_file(ctx,alias, list);
Quoted 3 lines
Quoted 3 lines
//Peter