]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
bridge: fix possible overflow in get_fdb_entries (CVE-2006-5751)
authorChris Wright <chrisw@sous-sol.org>
Mon, 4 Dec 2006 18:44:59 +0000 (19:44 +0100)
committerAdrian Bunk <bunk@stusta.de>
Mon, 4 Dec 2006 18:44:59 +0000 (19:44 +0100)
Make sure to properly clamp maxnum to avoid overflow (CVE-2006-5751).

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Acked-by: Stephen Hemminger <shemminger@osdl.org>
Acked-by: David Miller <davem@davemloft.net>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
net/bridge/br_ioctl.c

index 159fb84098241fdcc0a3a597d2d476cf80d78421..0d5b0d1ef25f9dfa9a0f4a9f7d66346281c49c8e 100644 (file)
@@ -58,12 +58,13 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
 {
        int num;
        void *buf;
-       size_t size = maxnum * sizeof(struct __fdb_entry);
+       size_t size;
 
-       if (size > PAGE_SIZE) {
-               size = PAGE_SIZE;
+       /* Clamp size to PAGE_SIZE, test maxnum to avoid overflow */
+       if (maxnum > PAGE_SIZE/sizeof(struct __fdb_entry))
                maxnum = PAGE_SIZE/sizeof(struct __fdb_entry);
-       }
+
+       size = maxnum * sizeof(struct __fdb_entry);
 
        buf = kmalloc(size, GFP_USER);
        if (!buf)