diff options
author | Chris Wright <chrisw@sous-sol.org> | 2006-11-20 18:02:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-11-28 20:26:50 -0500 |
commit | ba8379b220509e9448c00a77cf6c15ac2a559cc7 (patch) | |
tree | 53bba162f0a7e7e75849cea14e981e2f204ae478 /net/bridge/br_ioctl.c | |
parent | 24d7bb3396c51ceb2285e0e7b0c1bd1865652c43 (diff) |
[PATCH] bridge: fix possible overflow in get_fdb_entries
Make sure to properly clamp maxnum to avoid overflow
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Acked-by: Eugene Teo <eteo@redhat.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'net/bridge/br_ioctl.c')
-rw-r--r-- | net/bridge/br_ioctl.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c index 4e4119a12139..4c61a7e0a86e 100644 --- a/net/bridge/br_ioctl.c +++ b/net/bridge/br_ioctl.c | |||
@@ -58,12 +58,13 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf, | |||
58 | { | 58 | { |
59 | int num; | 59 | int num; |
60 | void *buf; | 60 | void *buf; |
61 | size_t size = maxnum * sizeof(struct __fdb_entry); | 61 | size_t size; |
62 | 62 | ||
63 | if (size > PAGE_SIZE) { | 63 | /* Clamp size to PAGE_SIZE, test maxnum to avoid overflow */ |
64 | size = PAGE_SIZE; | 64 | if (maxnum > PAGE_SIZE/sizeof(struct __fdb_entry)) |
65 | maxnum = PAGE_SIZE/sizeof(struct __fdb_entry); | 65 | maxnum = PAGE_SIZE/sizeof(struct __fdb_entry); |
66 | } | 66 | |
67 | size = maxnum * sizeof(struct __fdb_entry); | ||
67 | 68 | ||
68 | buf = kmalloc(size, GFP_USER); | 69 | buf = kmalloc(size, GFP_USER); |
69 | if (!buf) | 70 | if (!buf) |