* old buffer overflow in moxa driver
@ 2007-04-30 22:48 dann frazier
2007-04-30 23:04 ` Alan Cox
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: dann frazier @ 2007-04-30 22:48 UTC (permalink / raw)
To: linux-kernel; +Cc: Jiri Slaby, support, dilinger
hey,
I noticed that the moxa input checking security bug described by
CVE-2005-0504 appears to remain unfixed upstream.
The issue is described here:
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
Debian has been shipping the following patch from Andres Salomon. I
tried contacting the listed maintainer a few months ago but received
no response.
I've tested that this still applies to and compiles against 2.6.21.
Signed-off-by: dann frazier <dannf@hp.com>
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 7dbaee8..e0d35c2 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -1582,7 +1582,7 @@ copy:
if(copy_from_user(&dltmp, argp, sizeof(struct dl_str)))
return -EFAULT;
- if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS)
+ if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS || dltmp.len < 0)
return -EINVAL;
switch(cmd)
@@ -2529,6 +2529,8 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
void __iomem *baseAddr;
int i;
+ if(len < 0 || len > sizeof(moxaBuff))
+ return -EINVAL;
if(copy_from_user(moxaBuff, tmp, len))
return -EFAULT;
baseAddr = moxa_boards[cardno].basemem;
@@ -2576,7 +2578,7 @@ static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
void __iomem *baseAddr;
int i;
- if(len > sizeof(moxaBuff))
+ if(len < 0 || len > sizeof(moxaBuff))
return -EINVAL;
if(copy_from_user(moxaBuff, tmp, len))
return -EFAULT;
@@ -2596,6 +2598,8 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
void __iomem *baseAddr, *ofsAddr;
int retval, port, i;
+ if(len < 0 || len > sizeof(moxaBuff))
+ return -EINVAL;
if(copy_from_user(moxaBuff, tmp, len))
return -EFAULT;
baseAddr = moxa_boards[cardno].basemem;
--
dann frazier
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-04-30 22:48 old buffer overflow in moxa driver dann frazier
@ 2007-04-30 23:04 ` Alan Cox
2007-05-01 0:01 ` Ismail Dönmez
2007-05-01 7:58 ` Jiri Slaby
2007-05-01 4:05 ` Andres Salomon
2007-05-03 4:20 ` Andrew Morton
2 siblings, 2 replies; 10+ messages in thread
From: Alan Cox @ 2007-04-30 23:04 UTC (permalink / raw)
To: dann frazier; +Cc: linux-kernel, Jiri Slaby, support, dilinger
> I noticed that the moxa input checking security bug described by
> CVE-2005-0504 appears to remain unfixed upstream.
>
> The issue is described here:
> http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
>
> Debian has been shipping the following patch from Andres Salomon. I
> tried contacting the listed maintainer a few months ago but received
> no response.
case MOXA_LOAD_BIOS:
case MOXA_FIND_BOARD:
case MOXA_LOAD_C320B:
case MOXA_LOAD_CODE:
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
break;
At the point you abuse these calls you can already just load arbitary
data from userspace anyway.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-04-30 23:04 ` Alan Cox
@ 2007-05-01 0:01 ` Ismail Dönmez
2007-05-01 9:52 ` Alan Cox
2007-05-01 7:58 ` Jiri Slaby
1 sibling, 1 reply; 10+ messages in thread
From: Ismail Dönmez @ 2007-05-01 0:01 UTC (permalink / raw)
To: Alan Cox; +Cc: dann frazier, linux-kernel, Jiri Slaby, support, dilinger
[-- Attachment #1: Type: text/plain, Size: 1000 bytes --]
On Tuesday 01 May 2007 02:04:55 Alan Cox wrote:
> > I noticed that the moxa input checking security bug described by
> > CVE-2005-0504 appears to remain unfixed upstream.
> >
> > The issue is described here:
> > http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
> >
> > Debian has been shipping the following patch from Andres Salomon. I
> > tried contacting the listed maintainer a few months ago but received
> > no response.
>
> case MOXA_LOAD_BIOS:
> case MOXA_FIND_BOARD:
> case MOXA_LOAD_C320B:
> case MOXA_LOAD_CODE:
> if (!capable(CAP_SYS_RAWIO))
> return -EPERM;
> break;
>
> At the point you abuse these calls you can already just load arbitary
> data from userspace anyway.
So the possible exploit will only work when run by root, is that what you
mean? If so isn't that still a security problem?
Sorry if I misunderstood what you said.
Regards,
ismail
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-04-30 22:48 old buffer overflow in moxa driver dann frazier
2007-04-30 23:04 ` Alan Cox
@ 2007-05-01 4:05 ` Andres Salomon
2007-05-03 4:20 ` Andrew Morton
2 siblings, 0 replies; 10+ messages in thread
From: Andres Salomon @ 2007-05-01 4:05 UTC (permalink / raw)
To: dann frazier; +Cc: linux-kernel, Jiri Slaby, support
Wow, I'd forgotten all about this one.
Signed-off-by: Andres Salomon <dilinger@debian.org>
dann frazier wrote:
> hey,
> I noticed that the moxa input checking security bug described by
> CVE-2005-0504 appears to remain unfixed upstream.
>
> The issue is described here:
> http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
>
> Debian has been shipping the following patch from Andres Salomon. I
> tried contacting the listed maintainer a few months ago but received
> no response.
>
> I've tested that this still applies to and compiles against 2.6.21.
>
> Signed-off-by: dann frazier <dannf@hp.com>
>
> diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
> index 7dbaee8..e0d35c2 100644
> --- a/drivers/char/moxa.c
> +++ b/drivers/char/moxa.c
> @@ -1582,7 +1582,7 @@ copy:
>
> if(copy_from_user(&dltmp, argp, sizeof(struct dl_str)))
> return -EFAULT;
> - if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS)
> + if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS || dltmp.len < 0)
> return -EINVAL;
>
> switch(cmd)
> @@ -2529,6 +2529,8 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
> void __iomem *baseAddr;
> int i;
>
> + if(len < 0 || len > sizeof(moxaBuff))
> + return -EINVAL;
> if(copy_from_user(moxaBuff, tmp, len))
> return -EFAULT;
> baseAddr = moxa_boards[cardno].basemem;
> @@ -2576,7 +2578,7 @@ static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
> void __iomem *baseAddr;
> int i;
>
> - if(len > sizeof(moxaBuff))
> + if(len < 0 || len > sizeof(moxaBuff))
> return -EINVAL;
> if(copy_from_user(moxaBuff, tmp, len))
> return -EFAULT;
> @@ -2596,6 +2598,8 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
> void __iomem *baseAddr, *ofsAddr;
> int retval, port, i;
>
> + if(len < 0 || len > sizeof(moxaBuff))
> + return -EINVAL;
> if(copy_from_user(moxaBuff, tmp, len))
> return -EFAULT;
> baseAddr = moxa_boards[cardno].basemem;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-04-30 23:04 ` Alan Cox
2007-05-01 0:01 ` Ismail Dönmez
@ 2007-05-01 7:58 ` Jiri Slaby
2007-05-01 8:29 ` Andres Salomon
1 sibling, 1 reply; 10+ messages in thread
From: Jiri Slaby @ 2007-05-01 7:58 UTC (permalink / raw)
To: Alan Cox; +Cc: dann frazier, linux-kernel, support, dilinger
Alan Cox napsal(a):
>> I noticed that the moxa input checking security bug described by
>> CVE-2005-0504 appears to remain unfixed upstream.
>>
>> The issue is described here:
>> http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
>>
>> Debian has been shipping the following patch from Andres Salomon. I
>> tried contacting the listed maintainer a few months ago but received
>> no response.
>
>
> case MOXA_LOAD_BIOS:
> case MOXA_FIND_BOARD:
> case MOXA_LOAD_C320B:
> case MOXA_LOAD_CODE:
> if (!capable(CAP_SYS_RAWIO))
> return -EPERM;
> break;
>
> At the point you abuse these calls you can already just load arbitary
> data from userspace anyway.
The problem is that we BUG_ON, when len < 0 in copy_from_user which is unlikely
something we want to cause?
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-05-01 7:58 ` Jiri Slaby
@ 2007-05-01 8:29 ` Andres Salomon
2007-05-01 14:49 ` dann frazier
0 siblings, 1 reply; 10+ messages in thread
From: Andres Salomon @ 2007-05-01 8:29 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Alan Cox, dann frazier, linux-kernel, support
Jiri Slaby wrote:
> Alan Cox napsal(a):
>>> I noticed that the moxa input checking security bug described by
>>> CVE-2005-0504 appears to remain unfixed upstream.
>>>
>>> The issue is described here:
>>> http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
>>>
>>> Debian has been shipping the following patch from Andres Salomon. I
>>> tried contacting the listed maintainer a few months ago but received
>>> no response.
>>
>> case MOXA_LOAD_BIOS:
>> case MOXA_FIND_BOARD:
>> case MOXA_LOAD_C320B:
>> case MOXA_LOAD_CODE:
>> if (!capable(CAP_SYS_RAWIO))
>> return -EPERM;
>> break;
>>
>> At the point you abuse these calls you can already just load arbitary
>> data from userspace anyway.
>
> The problem is that we BUG_ON, when len < 0 in copy_from_user which is unlikely
> something we want to cause?
>
> regards,
Right; the lack of input checking is most definitely a bug. It's no
longer a security issue, as a CAP_SYS_RAWIO check was added at some
point to the code path, but it's still a bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-05-01 0:01 ` Ismail Dönmez
@ 2007-05-01 9:52 ` Alan Cox
2007-05-01 10:03 ` Jiri Slaby
0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2007-05-01 9:52 UTC (permalink / raw)
To: Ismail Dönmez
Cc: dann frazier, linux-kernel, Jiri Slaby, support, dilinger
> > At the point you abuse these calls you can already just load arbitary
> > data from userspace anyway.
>
> So the possible exploit will only work when run by root, is that what you
> mean? If so isn't that still a security problem?
To exploit the hole you need CAP_SYS_RAWIO which is the highest
capability of all. CAP_SYS_RAWIO gives you the ability to access hardware
directly so since it checks for CAP_SYS_RAWIO it isn't security.
The patch isn't wrong however and adds some sanity checking so it would
do no harm to send it to Andrew for -mm testing.
Alan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-05-01 9:52 ` Alan Cox
@ 2007-05-01 10:03 ` Jiri Slaby
0 siblings, 0 replies; 10+ messages in thread
From: Jiri Slaby @ 2007-05-01 10:03 UTC (permalink / raw)
To: Alan Cox
Cc: Ismail Dönmez, dann frazier, linux-kernel, support, dilinger
On 5/1/07, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > > At the point you abuse these calls you can already just load arbitary
> > > data from userspace anyway.
> >
> > So the possible exploit will only work when run by root, is that what you
> > mean? If so isn't that still a security problem?
>
> To exploit the hole you need CAP_SYS_RAWIO which is the highest
> capability of all. CAP_SYS_RAWIO gives you the ability to access hardware
> directly so since it checks for CAP_SYS_RAWIO it isn't security.
I understand that, but without it, the driver might seem buggy as far
as the person with permissions can write bad values and cause BUG().
On the other hand if the user has CAP_SYS_RAWIO, he has access to
/dev/{k,}mem anyway ;).
> The patch isn't wrong however and adds some sanity checking so it would
> do no harm to send it to Andrew for -mm testing.
Yes.
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-05-01 8:29 ` Andres Salomon
@ 2007-05-01 14:49 ` dann frazier
0 siblings, 0 replies; 10+ messages in thread
From: dann frazier @ 2007-05-01 14:49 UTC (permalink / raw)
To: Andres Salomon; +Cc: Jiri Slaby, Alan Cox, linux-kernel, support
On Tue, May 01, 2007 at 04:29:27AM -0400, Andres Salomon wrote:
> Right; the lack of input checking is most definitely a bug. It's no
> longer a security issue, as a CAP_SYS_RAWIO check was added at some
> point to the code path, but it's still a bug.
I hadn't noticed this, but yes - the CAP_SYS_RAWIO check was added in
2.6.16.
--
dann frazier | HP Open Source and Linux Organization
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: old buffer overflow in moxa driver
2007-04-30 22:48 old buffer overflow in moxa driver dann frazier
2007-04-30 23:04 ` Alan Cox
2007-05-01 4:05 ` Andres Salomon
@ 2007-05-03 4:20 ` Andrew Morton
2 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2007-05-03 4:20 UTC (permalink / raw)
To: dann frazier; +Cc: linux-kernel, Jiri Slaby, support, dilinger
On Mon, 30 Apr 2007 16:48:29 -0600 dann frazier <dannf@hp.com> wrote:
> hey,
> I noticed that the moxa input checking security bug described by
> CVE-2005-0504 appears to remain unfixed upstream.
>
> The issue is described here:
> http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0504
>
> Debian has been shipping the following patch from Andres Salomon. I
> tried contacting the listed maintainer a few months ago but received
> no response.
>
> I've tested that this still applies to and compiles against 2.6.21.
>
> Signed-off-by: dann frazier <dannf@hp.com>
>
> diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
> index 7dbaee8..e0d35c2 100644
> --- a/drivers/char/moxa.c
> +++ b/drivers/char/moxa.c
> @@ -1582,7 +1582,7 @@ copy:
>
> if(copy_from_user(&dltmp, argp, sizeof(struct dl_str)))
> return -EFAULT;
> - if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS)
> + if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS || dltmp.len < 0)
> return -EINVAL;
>
> switch(cmd)
> @@ -2529,6 +2529,8 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
> void __iomem *baseAddr;
> int i;
>
> + if(len < 0 || len > sizeof(moxaBuff))
> + return -EINVAL;
> if(copy_from_user(moxaBuff, tmp, len))
> return -EFAULT;
> baseAddr = moxa_boards[cardno].basemem;
> @@ -2576,7 +2578,7 @@ static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
> void __iomem *baseAddr;
> int i;
>
> - if(len > sizeof(moxaBuff))
> + if(len < 0 || len > sizeof(moxaBuff))
> return -EINVAL;
> if(copy_from_user(moxaBuff, tmp, len))
> return -EFAULT;
> @@ -2596,6 +2598,8 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
> void __iomem *baseAddr, *ofsAddr;
> int retval, port, i;
>
> + if(len < 0 || len > sizeof(moxaBuff))
> + return -EINVAL;
> if(copy_from_user(moxaBuff, tmp, len))
> return -EFAULT;
> baseAddr = moxa_boards[cardno].basemem;
>
I'm seeing copies of this patch floating around the internet from the 2.6.10
timeframe at least.
Could people please be more diligent about getting bugfixes back into
mainline?
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-05-03 4:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-30 22:48 old buffer overflow in moxa driver dann frazier
2007-04-30 23:04 ` Alan Cox
2007-05-01 0:01 ` Ismail Dönmez
2007-05-01 9:52 ` Alan Cox
2007-05-01 10:03 ` Jiri Slaby
2007-05-01 7:58 ` Jiri Slaby
2007-05-01 8:29 ` Andres Salomon
2007-05-01 14:49 ` dann frazier
2007-05-01 4:05 ` Andres Salomon
2007-05-03 4:20 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox