* [bug report] cxd2820r: dynamically allocated arrays
@ 2011-05-25 14:42 Dan Carpenter
2011-05-25 14:48 ` Antti Palosaari
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-05-25 14:42 UTC (permalink / raw)
To: Steve Kerrison; +Cc: Antti Palosaari, Mauro Carvalho Chehab, linux-media
This driver has several places that use dynamically sized arrays.
It's dangerous to do that in the kernel because the kernel has a
very small stack. A bug could cause the stack to overflow and
corrupt memory. I seem to recall i2c transfers can be triggered by
the users but I don't know the details (ie security implications).
Here is an example of what I mean:
static int cxd2820r_tuner_i2c_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg msg[], int num)
{
struct cxd2820r_priv *priv = i2c_get_adapdata(i2c_adap);
u8 obuf[msg[0].len + 2];
^^^^^^^^^^
struct i2c_msg msg2[2] = {
If msg[0].len is too long it will overflow.
Here is the sparse output for the file:
CHECK drivers/media/dvb/frontends/cxd2820r_core.c
drivers/media/dvb/frontends/cxd2820r.h:58:30: error: dubious one-bit signed bitfield
drivers/media/dvb/frontends/cxd2820r.h:64:23: error: dubious one-bit signed bitfield
drivers/media/dvb/frontends/cxd2820r_priv.h:58:26: error: dubious one-bit signed bitfield
drivers/media/dvb/frontends/cxd2820r_priv.h:64:31: error: dubious one-bit signed bitfield
drivers/media/dvb/frontends/cxd2820r_core.c:33:19: error: bad constant expression
drivers/media/dvb/frontends/cxd2820r_core.c:38:32: error: cannot size expression
drivers/media/dvb/frontends/cxd2820r_core.c:61:16: error: bad constant expression
drivers/media/dvb/frontends/cxd2820r_core.c:71:32: error: cannot size expression
drivers/media/dvb/frontends/cxd2820r_core.c:743:28: error: bad constant expression
drivers/media/dvb/frontends/cxd2820r_core.c:748:32: error: cannot size expression
drivers/media/dvb/frontends/cxd2820r_core.c:762:31: error: cannot size expression
CC [M] drivers/media/dvb/frontends/cxd2820r_core.o
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [bug report] cxd2820r: dynamically allocated arrays
2011-05-25 14:42 [bug report] cxd2820r: dynamically allocated arrays Dan Carpenter
@ 2011-05-25 14:48 ` Antti Palosaari
0 siblings, 0 replies; 2+ messages in thread
From: Antti Palosaari @ 2011-05-25 14:48 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Steve Kerrison, Mauro Carvalho Chehab, linux-media
Hello Dan,
I am just fixing those and also some other fixes.
regards,
Antti
On 05/25/2011 05:42 PM, Dan Carpenter wrote:
> This driver has several places that use dynamically sized arrays.
> It's dangerous to do that in the kernel because the kernel has a
> very small stack. A bug could cause the stack to overflow and
> corrupt memory. I seem to recall i2c transfers can be triggered by
> the users but I don't know the details (ie security implications).
>
> Here is an example of what I mean:
>
> static int cxd2820r_tuner_i2c_xfer(struct i2c_adapter *i2c_adap,
> struct i2c_msg msg[], int num)
> {
> struct cxd2820r_priv *priv = i2c_get_adapdata(i2c_adap);
> u8 obuf[msg[0].len + 2];
> ^^^^^^^^^^
> struct i2c_msg msg2[2] = {
>
> If msg[0].len is too long it will overflow.
>
> Here is the sparse output for the file:
>
> CHECK drivers/media/dvb/frontends/cxd2820r_core.c
> drivers/media/dvb/frontends/cxd2820r.h:58:30: error: dubious one-bit signed bitfield
> drivers/media/dvb/frontends/cxd2820r.h:64:23: error: dubious one-bit signed bitfield
> drivers/media/dvb/frontends/cxd2820r_priv.h:58:26: error: dubious one-bit signed bitfield
> drivers/media/dvb/frontends/cxd2820r_priv.h:64:31: error: dubious one-bit signed bitfield
> drivers/media/dvb/frontends/cxd2820r_core.c:33:19: error: bad constant expression
> drivers/media/dvb/frontends/cxd2820r_core.c:38:32: error: cannot size expression
> drivers/media/dvb/frontends/cxd2820r_core.c:61:16: error: bad constant expression
> drivers/media/dvb/frontends/cxd2820r_core.c:71:32: error: cannot size expression
> drivers/media/dvb/frontends/cxd2820r_core.c:743:28: error: bad constant expression
> drivers/media/dvb/frontends/cxd2820r_core.c:748:32: error: cannot size expression
> drivers/media/dvb/frontends/cxd2820r_core.c:762:31: error: cannot size expression
> CC [M] drivers/media/dvb/frontends/cxd2820r_core.o
>
> regards,
> dan carpenter
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-25 14:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-25 14:42 [bug report] cxd2820r: dynamically allocated arrays Dan Carpenter
2011-05-25 14:48 ` Antti Palosaari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox