commit ba8379b220509e9448c00a77cf6c15ac2a559cc7
tree 53bba162f0a7e7e75849cea14e981e2f204ae478
parent 24d7bb3396c51ceb2285e0e7b0c1bd1865652c43
author Chris Wright <[EMAIL PROTECTED]> 1164063769 -0800
committer Linus Torvalds <[EMAIL PROTECTED]> 1164763610 -0800

[PATCH] bridge: fix possible overflow in get_fdb_entries

Make sure to properly clamp maxnum to avoid overflow

Signed-off-by: Chris Wright <[EMAIL PROTECTED]>
Acked-by: Eugene Teo <[EMAIL PROTECTED]>
Acked-by: Marcel Holtmann <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>

 net/bridge/br_ioctl.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index 4e4119a..4c61a7e 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -58,12 +58,13 @@ static int get_fdb_entries(struct net_br
 {
        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)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to