Commit e0d34fea authored by Chris Wright's avatar Chris Wright Committed by Adrian Bunk

bridge: fix possible overflow in get_fdb_entries (CVE-2006-5751)

Make sure to properly clamp maxnum to avoid overflow (CVE-2006-5751).
Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
Acked-by: default avatarStephen Hemminger <shemminger@osdl.org>
Acked-by: default avatarDavid Miller <davem@davemloft.net>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent 25e1dd8a
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment