git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
net
/
bridge
/
br_ioctl.c
diff --git
a/net/bridge/br_ioctl.c
b/net/bridge/br_ioctl.c
index
cceb018
..
4c61a7e
100644
(file)
--- a/
net/bridge/br_ioctl.c
+++ b/
net/bridge/br_ioctl.c
@@
-13,6
+13,7
@@
* 2 of the License, or (at your option) any later version.
*/
* 2 of the License, or (at your option) any later version.
*/
+#include <linux/capability.h>
#include <linux/kernel.h>
#include <linux/if_bridge.h>
#include <linux/netdevice.h>
#include <linux/kernel.h>
#include <linux/if_bridge.h>
#include <linux/netdevice.h>
@@
-57,12
+58,13
@@
static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
{
int num;
void *buf;
{
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);
maxnum = PAGE_SIZE/sizeof(struct __fdb_entry);
- }
+
+ size = maxnum * sizeof(struct __fdb_entry);
buf = kmalloc(size, GFP_USER);
if (!buf)
buf = kmalloc(size, GFP_USER);
if (!buf)
@@
-161,12
+163,10
@@
static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
if (num > BR_MAX_PORTS)
num = BR_MAX_PORTS;
if (num > BR_MAX_PORTS)
num = BR_MAX_PORTS;
- indices = k
malloc(num*
sizeof(int), GFP_KERNEL);
+ indices = k
calloc(num,
sizeof(int), GFP_KERNEL);
if (indices == NULL)
return -ENOMEM;
if (indices == NULL)
return -ENOMEM;
- memset(indices, 0, num*sizeof(int));
-
get_port_ifindices(br, indices, num);
if (copy_to_user((void __user *)args[1], indices, num*sizeof(int)))
num = -EFAULT;
get_port_ifindices(br, indices, num);
if (copy_to_user((void __user *)args[1], indices, num*sizeof(int)))
num = -EFAULT;
@@
-324,11
+324,12
@@
static int old_deviceless(void __user *uarg)
int *indices;
int ret = 0;
int *indices;
int ret = 0;
- indices = kmalloc(args[2]*sizeof(int), GFP_KERNEL);
+ if (args[2] >= 2048)
+ return -ENOMEM;
+ indices = kcalloc(args[2], sizeof(int), GFP_KERNEL);
if (indices == NULL)
return -ENOMEM;
if (indices == NULL)
return -ENOMEM;
- memset(indices, 0, args[2]*sizeof(int));
args[2] = get_bridge_ifindices(indices, args[2]);
ret = copy_to_user((void __user *)args[1], indices, args[2]*sizeof(int))
args[2] = get_bridge_ifindices(indices, args[2]);
ret = copy_to_user((void __user *)args[1], indices, args[2]*sizeof(int))
@@
-403,6
+404,6
@@
int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
}
}
- pr
intk(KERN_DEBUG
"Bridge does not support ioctl 0x%x\n", cmd);
+ pr
_debug(
"Bridge does not support ioctl 0x%x\n", cmd);
return -EOPNOTSUPP;
}
return -EOPNOTSUPP;
}