OSDN Git Service

old buffer overflow in moxa driver (CVE-2005-0504)
authordann frazier <dannf@hp.com>
Tue, 8 May 2007 07:31:39 +0000 (00:31 -0700)
committerWilly Tarreau <w@1wt.eu>
Sun, 1 Jun 2008 18:23:56 +0000 (20:23 +0200)
[backport of 2.6 commit a2f72982e22b96862f8f15272732bd316d4db040]

old buffer overflow in moxa driver

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.

(akpm: it's a privileged operation)

Signed-off-by: dann frazier <dannf@hp.com>
Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/char/moxa.c

index 341b8e0..b67e8d6 100644 (file)
@@ -1763,7 +1763,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
 
        if(copy_from_user(&dltmp, (void *)arg, 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)
@@ -2874,6 +2874,8 @@ static int moxaloadbios(int cardno, unsigned char *tmp, int len)
        unsigned long baseAddr;
        int i;
 
+       if(len < 0 || len > sizeof(moxaBuff))
+               return -EINVAL;
        if(copy_from_user(moxaBuff, tmp, len))
                return -EFAULT;
        baseAddr = moxaBaseAddr[cardno];
@@ -2921,7 +2923,7 @@ static int moxaload320b(int cardno, unsigned char * tmp, int len)
        unsigned long baseAddr;
        int i;
 
-       if(len > sizeof(moxaBuff))
+       if(len < 0 || len > sizeof(moxaBuff))
                return -EINVAL;
        if(copy_from_user(moxaBuff, tmp, len))
                return -EFAULT;
@@ -2941,6 +2943,8 @@ static int moxaloadcode(int cardno, unsigned char * tmp, int len)
        unsigned long baseAddr, ofsAddr;
        int retval, port, i;
 
+       if(len < 0 || len > sizeof(moxaBuff))
+               return -EINVAL;
        if(copy_from_user(moxaBuff, tmp, len))
                return -EFAULT;
        baseAddr = moxaBaseAddr[cardno];