driver-core: fix modparam async_probe request
PATCH RESEND 1/1 driver-core: fix modparam async_probe request
From: "Luis R. Rodriguez" <[email protected]>
Commit f2411da746985 ("driver-core: add driver module asynchronous probe support") added async probe support, in two forms:
* in-kernel driver specification annotation
* generic async_probe module parameter (modprobe foo async_probe)
To support the generic kernel parameter parse_args() was extended via commit ecc8617053e0 ("module: add extra argument for parse_params() callback") however commit failed to f2411da746985 failed to add the required argument.
This causes a crash then whenever async_probe generic module parameter is used. This was overlooked when the form in which in-kernel async probe support was reworked a bit... Fix this as originally intended.
---
Resending and addressing Rusty, the other patch I sent on Dec 19 was addressed to Greg by mistake. Sorry about that.
kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/module.c +8 -2
@@ -3402,16 +3402,22 @@ out:static int unknown_module_param_cb (char *param,char *val,const char *modname,void *arg) { -struct module *mod = arg; +struct module *mod;int ret;if (strcmp (param,"async_probe" ) ==0 ) { + mod = arg; +if (!mod) { + ret = -ENOENT ; + goto out; + } mod->async_probe_requested = true;return 0 ; }/* Check for magic 'dyndbg' arg */ ret =ddebug_dyndbg_module_param_cb (param, val, modname); +out:if (ret !=0 )pr_warn ("%s: unknown parameter '%s' ignored\n" , modname, param);return 0 ;
@@ -3515,7 +3521,7 @@ static int load_module(struct load_info *info, const char __user *uargs,/* Module is ready to execute: parsing args may do that. */ after_dashes =parse_args (mod->name, mod->args, mod->kp, mod->num_kp, --32768 ,32767 ,NULL , +-32768 ,32767 , mod, unknown_module_param_cb);if (IS_ERR (after_dashes)) { err =PTR_ERR (after_dashes);
Signature · 1 line
2.6.2
Hi Luis,
Quoted 39 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Commit
f2411da746985("driver-core: add driver module asynchronous probe support") added async probe support, in two forms:* in-kernel driver specification annotation
* genericasync_probemodule parameter (modprobe fooasync_probe)To support the generic kernel parameter
parse_args()was extended via commitecc8617053e0("module: add extra argument forparse_params()callback") however commit failed tof2411da746985failed to add the required argument.This causes a crash then whenever
async_probegeneric module parameter is used. This was overlooked when the form in which in-kernel async probe support was reworked a bit... Fix this as originally intended.Cc Hannes Reinecke <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc [email protected] (4.2+)Signed-off-by Luis R. Rodriguez <[email protected]>---
Resending and addressing Rusty, the other patch I sent on Dec 19 was addressed to Greg by mistake. Sorry about that.
kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kernel/module.c +0
-0@@ -3402,16 +3402,22 @@ out:static int unknown_module_param_cb (char *param,char *val,const char *modname,void *arg) {
kernel/module.c out: · line 3413
Quoted 10 lines
kernel/module.c +6
-1-struct module *mod = arg; +struct module *mod;int ret;if (strcmp (param,"async_probe" ) ==0 ) { + mod = arg; +if (!mod) { + ret = -ENOENT ; + goto out; + }
Why do we need this chunk? We only call unknown_module_param_cb() from one place and with your chunk below we do know that "mod" is never NULL.
Quoted 11 lines
kernel/module.c +1
-0mod->async_probe_requested = true;return 0 ; }/* Check for magic 'dyndbg' arg */ ret =ddebug_dyndbg_module_param_cb (param, val, modname); +out:if (ret !=0 )pr_warn ("%s: unknown parameter '%s' ignored\n" , modname, param);return 0 ;
kernel/module.c static int load_module(struct load_info *info, const char __user *uargs, · line 3524
Quoted 5 lines
kernel/module.c +1
-1@@ -3515,7 +3521,7 @@ static int load_module(struct load_info *info, const char __user *uargs,/* Module is ready to execute: parsing args may do that. */ after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, - -32768, 32767, NULL, + -32768, 32767, mod,
I believe this is the only change that is needed.
Quoted 6 lines
kernel/module.c +0
-0unknown_module_param_cb);if (IS_ERR (after_dashes)) { err =PTR_ERR (after_dashes);Signature · 1 line
2.6.2
Thanks.
Signature · 1 line
Dmitry
Quoted 46 lines · Dmitry Torokhov
Hi Luis,
Quoted 43 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Commit
f2411da746985("driver-core: add driver module asynchronous probe support") added async probe support, in two forms:* in-kernel driver specification annotation
* genericasync_probemodule parameter (modprobe fooasync_probe)To support the generic kernel parameter
parse_args()was extended via commitecc8617053e0("module: add extra argument forparse_params()callback") however commit failed tof2411da746985failed to add the required argument.This causes a crash then whenever
async_probegeneric module parameter is used. This was overlooked when the form in which in-kernel async probe support was reworked a bit... Fix this as originally intended.Cc Hannes Reinecke <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc [email protected] (4.2+)Signed-off-by Luis R. Rodriguez <[email protected]>---
Resending and addressing Rusty, the other patch I sent on Dec 19 was addressed to Greg by mistake. Sorry about that.
kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kernel/module.c +1
-1@@ -3402,16 +3402,22 @@ out:static int unknown_module_param_cb (char *param,char *val,const char *modname,void *arg) { -struct module *mod = arg; +struct module *mod;int ret;
Quoted 9 lines
kernel/module.c out: · line 3413
Quoted 6 lines
kernel/module.c +5
-0if (strcmp (param,"async_probe" ) ==0 ) { + mod = arg; +if (!mod) { + ret = -ENOENT ; + goto out; + }Why do we need this chunk? We only call
unknown_module_param_cb()from one place and with your chunk below we do know that "mod" is never NULL.
To prevent future bugs that might use this incorrectly.
Quoted 12 lines
Quoted 12 lines
kernel/module.c +1
-0mod->async_probe_requested = true;return 0 ; }/* Check for magic 'dyndbg' arg */ ret =ddebug_dyndbg_module_param_cb (param, val, modname); +out:if (ret !=0 )pr_warn ("%s: unknown parameter '%s' ignored\n" , modname, param);return 0 ;@@ -3515,7 +3521,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
Quoted 6 lines
kernel/module.c static int load_module(struct load_info *info, const char __user *uargs, · line 3524
Quoted 4 lines
kernel/module.c +1
-1/* Module is ready to execute: parsing args may do that. */ after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, - -32768, 32767, NULL, + -32768, 32767, mod,I believe this is the only change that is needed.
For the fix yes, that is true. We could split this in two. Up to Rusty.
Luis
Quoted 72 lines · Luis R. Rodriguez
Quoted 46 lines · Dmitry Torokhov
Hi Luis,
Quoted 43 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Commit
f2411da746985("driver-core: add driver module asynchronous probe support") added async probe support, in two forms:* in-kernel driver specification annotation
* genericasync_probemodule parameter (modprobe fooasync_probe)To support the generic kernel parameter
parse_args()was extended via commitecc8617053e0("module: add extra argument forparse_params()callback") however commit failed tof2411da746985failed to add the required argument.This causes a crash then whenever
async_probegeneric module parameter is used. This was overlooked when the form in which in-kernel async probe support was reworked a bit... Fix this as originally intended.Cc Hannes Reinecke <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc [email protected] (4.2+)Signed-off-by Luis R. Rodriguez <[email protected]>---
Resending and addressing Rusty, the other patch I sent on Dec 19 was addressed to Greg by mistake. Sorry about that.
kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)kernel/module.c +1
-1@@ -3402,16 +3402,22 @@ out:static int unknown_module_param_cb (char *param,char *val,const char *modname,void *arg) { -struct module *mod = arg; +struct module *mod;int ret;Quoted 9 lines
kernel/module.c out: · line 3413
Quoted 6 lines
kernel/module.c +5
-0if (strcmp (param,"async_probe" ) ==0 ) { + mod = arg; +if (!mod) { + ret = -ENOENT ; + goto out; + }Why do we need this chunk? We only call
unknown_module_param_cb()from one place and with your chunk below we do know that "mod" is never NULL.To prevent future bugs that might use this incorrectly.
Quoted 12 lines
Quoted 12 lines
kernel/module.c +1
-0mod->async_probe_requested = true;return 0 ; }/* Check for magic 'dyndbg' arg */ ret =ddebug_dyndbg_module_param_cb (param, val, modname); +out:if (ret !=0 )pr_warn ("%s: unknown parameter '%s' ignored\n" , modname, param);return 0 ;@@ -3515,7 +3521,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
Quoted 8 lines
Quoted 6 lines
kernel/module.c static int load_module(struct load_info *info, const char __user *uargs, · line 3524
Quoted 4 lines
kernel/module.c +1
-1/* Module is ready to execute: parsing args may do that. */ after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, - -32768, 32767, NULL, + -32768, 32767, mod,I believe this is the only change that is needed.
For the fix yes, that is true. We could split this in two. Up to Rusty.
Confused me, too. This function is static, so it's pretty clearly only called from one place.
I've applied the minimal fix, as below (and changed the Subject prefix to "modules").
Thanks!
Rusty.
From: Luis R. Rodriguez <[email protected]>
Subject: modules: fix modparam async_probe request
Commit f2411da746985 ("driver-core: add driver module asynchronous probe support") added async probe support, in two forms:
* in-kernel driver specification annotation
* generic async_probe module parameter (modprobe foo async_probe)
To support the generic kernel parameter parse_args() was extended via commit ecc8617053e0 ("module: add extra argument for parse_params() callback") however commit failed to f2411da746985 failed to add the required argument.
This causes a crash then whenever async_probe generic module parameter is used. This was overlooked when the form in which in-kernel async probe support was reworked a bit... Fix this as originally intended.
--- kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/module.c +1 -1
@@ -3496,7 +3502,7 @@ static int load_module(struct load_info *info, const char __user *uargs,/* Module is ready to execute: parsing args may do that. */ after_dashes =parse_args (mod->name, mod->args, mod->kp, mod->num_kp, --32768 ,32767 ,NULL , +-32768 ,32767 , mod, unknown_module_param_cb);if (IS_ERR (after_dashes)) { err =PTR_ERR (after_dashes);