From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: Dongdong Deng <dongdong.deng@windriver.com>
Cc: rusty@rustcorp.com.au, davem@davemloft.net,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
jason.wessel@windriver.com, lenb@kernel.org, dwmw2@infradead.org,
mdharm-usb@one-eyed-alien.net, bfields@fieldses.org,
robert.richter@amd.com
Subject: Re: [PATCH] module param_call: fix potential NULL pointer dereference
Date: Sun, 21 Feb 2010 16:41:36 +0800 [thread overview]
Message-ID: <2375c9f91002210041l1bf30871vdf3881589a654d5a@mail.gmail.com> (raw)
In-Reply-To: <1266737078-26186-1-git-send-email-dongdong.deng@windriver.com>
[-- Attachment #1: Type: text/plain, Size: 1407 bytes --]
On Sun, Feb 21, 2010 at 3:24 PM, Dongdong Deng
<dongdong.deng@windriver.com> wrote:
> The param_set_fn() function will get a parameter which is a NULL
> pointer when insmod module with params via following method:
>
> $insmod module.ko module_params
>
> BTW: the normal method usually as following format:
> $insmod module.ko module_params=example
>
> If the param_set_fn() function didn't check that parameter and used
> it directly, it could caused an OOPS due to NULL pointer dereference.
>
> The solution is simple:
> Just checking the parameter before using in param_set_fn().
>
> Example:
> int set_module_params(const char *val, struct kernel_param *kp)
> {
> /*Checking the val parameter before using */
> if (!val)
> return -EINVAL;
> ...
> }
> module_param_call(module_params, set_module_params, NULL, NULL, 0644);
>
Why not just checking all of them in the generic code?
How about my _untested_ patch below?
Thanks.
-----------
When a module parameter "foo" is not bool, we shouldn't accept arguments
like this "insmod ./foo.ko foo". However, currently only standard
->set functions
check this, several non-standard ->set functions ignore this, thus could cause
NULL def oops.
Reported-by: Dongdong Deng <dongdong.deng@windriver.com>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
---
[-- Attachment #2: kernel-params_c-check-null-for-non-bool.diff --]
[-- Type: text/plain, Size: 461 bytes --]
diff --git a/kernel/params.c b/kernel/params.c
index cf1b691..84a1466 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -59,6 +59,8 @@ static int parse_one(char *param,
/* Find parameter */
for (i = 0; i < num_params; i++) {
if (parameq(param, params[i].name)) {
+ if ((!params[i].flags & KPARAM_ISBOOL) && !val)
+ return -EINVAL;
DEBUGP("They are equal! Calling %p\n",
params[i].set);
return params[i].set(val, ¶ms[i]);
next prev parent reply other threads:[~2010-02-21 8:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-21 7:24 [PATCH] module param_call: fix potential NULL pointer dereference Dongdong Deng
2010-02-21 8:41 ` Américo Wang [this message]
2010-02-21 9:16 ` DDD
2010-02-22 7:37 ` Américo Wang
2010-02-22 9:11 ` Rusty Russell
2010-02-22 10:11 ` DDD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2375c9f91002210041l1bf30871vdf3881589a654d5a@mail.gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=bfields@fieldses.org \
--cc=davem@davemloft.net \
--cc=dongdong.deng@windriver.com \
--cc=dwmw2@infradead.org \
--cc=jason.wessel@windriver.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdharm-usb@one-eyed-alien.net \
--cc=netdev@vger.kernel.org \
--cc=robert.richter@amd.com \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).