Skip to content

Commit

Permalink
[PATCH] bridge: fix possible overflow in get_fdb_entries
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chris Wright authored and Linus Torvalds committed Nov 29, 2006
1 parent 24d7bb3 commit ba8379b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/bridge/br_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ba8379b

Please sign in to comment.