old buffer overflow in moxa driver
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.
drivers/char/moxa.c +6 -2
@@ -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;
Signature · 1 line
dann frazier
Quoted 9 lines
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-0504Debian 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.
Quoted 18 lines · On Tuesday 01 May 2007 02:04:55 Alan Cox wrote:
Quoted 9 lines
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-0504Debian 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;
Quoted 2 lines
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
Quoted 5 lines
Quoted 2 lines
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
Quoted 9 lines · Alan Cox
Quoted 5 lines
Quoted 2 lines
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_RAWIOwhich is the highest capability of all.CAP_SYS_RAWIOgives you the ability to access hardware directly so since it checks forCAP_SYS_RAWIOit 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 ;).
Quoted 2 lines
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,
Signature · 4 lines
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
Alan Cox napsal(a):
Quoted 19 lines
Quoted 9 lines
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-0504Debian 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;
Quoted 2 lines
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,
Signature · 4 lines
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
Quoted 19 lines · Jiri Slaby
Alan Cox napsal(a):
Quoted 18 lines
Quoted 9 lines
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-0504Debian 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;
Quoted 7 lines
Quoted 2 lines
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 incopy_from_userwhich 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.
Quoted 3 lines · Andres Salomon
Right; the lack of input checking is most definitely a bug. It's no longer a security issue, as a
CAP_SYS_RAWIOcheck 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.
Signature · 1 line
dann frazier | HP Open Source and Linux Organization
Wow, I'd forgotten all about this one.
Quoted 56 lines · dann frazier
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-0504Debian 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 <[email protected]>drivers/char/moxa.c +6
-2@@ -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;
Quoted 48 lines · On Mon, 30 Apr 2007 16:48:29 -0600 dann frazier <[email protected]> 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-0504Debian 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 <[email protected]>drivers/char/moxa.c +4
-2@@ -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 ;
drivers/char/moxa.c static int moxaloadcode(int cardno, unsigned char __user *tmp, int len) · line 2605
Quoted 8 lines
drivers/char/moxa.c +2
-0@@ -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?