libkmod: ignore kcmdline option if we fail to parse modname
PATCH 1/2 libkmod: ignore kcmdline option if we fail to parse modname
The error message is saying we are ignoring the option on the kernel command line, so just do it.
--- libkmod/libkmod-config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libkmod/libkmod-config.c +2 -1
@@ -488,8 +488,9 @@ static void kcmdline_parse_result(struct kmod_config *config, char *modname,if (underscores (modname) <0 ) {ERR (config->ctx,"Ignoring bad option on kernel command line while parsing module name: '%s'\n" , modname); + }else { +kmod_config_add_options (config, modname, param); } -kmod_config_add_options (config, modname, param); } }
Signature · 1 line
2.25.1
PATCH 2/2 testsuite: check for ill-formed kcmdline
Commit ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter") in the kernel introduced an ill-formed kernel parameter, ivrs_acpihid. The problem is that it may have a dot on the key side:
"ivrs_acpihid[00:14.5]=AMD0020:0". This could potentially trip our parser of module options, but right now it's working as intended: the only thing that happens is that after deciding "ivrs_acpihid[00:14" is a module name, it will fail the underscores() routine and the option will be ignored from the kmod pov (not kernel's pov since that driver parsers the kernel command line by itself).
--- .../module-param-kcmdline6/correct.txt | 6 +++++ .../module-param-kcmdline6/proc/cmdline | 1 + testsuite/test-modprobe.c | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt create mode 100644 testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline
testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt new file +6 -0
@@ -0,0 +1,6 @@ +options psmouse foo=2 +options psmouse bar=1 +options psmouse zinga=test + +# End of configuration files. Dumping indexes now: +
testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline new file +1 -0
@@ -0,0 +1 @@ +psmouse.foo=2 ivrs_acpihid[14:00.5]=AMD0020:00 psmouse.bar=1 psmouse.zinga=test
testsuite/test-modprobe.c +25 -0
@@ -328,6 +328,31 @@ DEFINE_TEST(modprobe_param_kcmdline5, ); +static noreturnint modprobe_param_kcmdline6 (const struct test *t) +{ +const char *progname =ABS_TOP_BUILDDIR "/tools/modprobe" ; +const char *const args[] = { + progname, +"-c" , +NULL , + }; + +test_spawn_prog (progname, args); +exit (EXIT_FAILURE ); +} +DEFINE_TEST(modprobe_param_kcmdline6, + .description = "check if dots on other parts of kcmdline don't confuse our parser", + .config = { + [TC_UNAME_R] = "4.4.4", + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6", + }, + .output = { + .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6/correct.txt", + }, + .modules_loaded = "", + ); + +static noreturnint modprobe_force (const struct test *t) {const char *progname =ABS_TOP_BUILDDIR "/tools/modprobe" ;
Signature · 1 line
2.25.1
Both patches applied.
Lucas De Marchi
Quoted 24 lines · Lucas De Marchi
The error message is saying we are ignoring the option on the kernel command line, so just do it.
---libkmod/libkmod-config.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)libkmod/libkmod-config.c +2
-1@@ -488,8 +488,9 @@ static void kcmdline_parse_result(struct kmod_config *config, char *modname,if (underscores (modname) <0 ) {ERR (config->ctx,"Ignoring bad option on kernel command line while parsing module name: '%s'\n" , modname); + }else { +kmod_config_add_options (config, modname, param); } -kmod_config_add_options (config, modname, param); } }Signature · 1 line
2.25.1