[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201002221941.21662.rusty@rustcorp.com.au>
Date: Mon, 22 Feb 2010 19:41:21 +1030
From: Rusty Russell <rusty@...tcorp.com.au>
To: Américo Wang <xiyou.wangcong@...il.com>
Cc: Dongdong Deng <dongdong.deng@...driver.com>, davem@...emloft.net,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
jason.wessel@...driver.com, lenb@...nel.org, dwmw2@...radead.org,
mdharm-usb@...-eyed-alien.net, bfields@...ldses.org,
robert.richter@....com
Subject: Re: [PATCH] module param_call: fix potential NULL pointer dereference
On Sun, 21 Feb 2010 07:11:36 pm Américo Wang wrote:
> On Sun, Feb 21, 2010 at 3:24 PM, Dongdong Deng
> <dongdong.deng@...driver.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?
It seemed useful to allow 'foo' as well as 'foo='. But given these examples,
obviously that was too easy to misuse.
So I like your patch; please annotate it properly and put a comment
like:
/* We used to hand NULL for bare params, but most code didn't handle it :( */
I assume none of those non-standard param parsers *want* to handle NULL?
Thanks,
Rusty.
--
Away travelling 25Feb-26Mar (6 .de + 1 .pl + 17 .lt + 2 .sg)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists