All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: cgroup: fix out of bounds accesses
@ 2012-07-09  7:45 Eric Dumazet
  2012-07-09  8:15 ` Gao feng
  2012-07-09 11:01 ` Neil Horman
  0 siblings, 2 replies; 15+ messages in thread
From: Eric Dumazet @ 2012-07-09  7:45 UTC (permalink / raw)
  To: David Miller; +Cc: nhorman, linux-kernel, netdev, lizefan, tj, Gao feng

From: Eric Dumazet <edumazet@google.com>

dev->priomap is allocated by extend_netdev_table() called from
update_netdev_tables().
And this is only called if write_priomap() is called.

But if write_priomap() is not called, it seems we can have out of bounds
accesses in cgrp_destroy(), read_priomap() & skb_update_prio()

With help from Gao Feng

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Gao feng <gaofeng@cn.fujitsu.com>
---
net/core/dev.c            |    8 ++++++--
net/core/netprio_cgroup.c |    4 ++--
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 84f01ba..0f28a9e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2444,8 +2444,12 @@ static void skb_update_prio(struct sk_buff *skb)
 {
 	struct netprio_map *map = rcu_dereference_bh(skb->dev->priomap);
 
-	if ((!skb->priority) && (skb->sk) && map)
-		skb->priority = map->priomap[skb->sk->sk_cgrp_prioidx];
+	if (!skb->priority && skb->sk && map) {
+		unsigned int prioidx = skb->sk->sk_cgrp_prioidx;
+
+		if (prioidx < map->priomap_len)
+			skb->priority = map->priomap[prioidx];
+	}
 }
 #else
 #define skb_update_prio(skb)
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index aa907ed..3e953ea 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -142,7 +142,7 @@ static void cgrp_destroy(struct cgroup *cgrp)
 	rtnl_lock();
 	for_each_netdev(&init_net, dev) {
 		map = rtnl_dereference(dev->priomap);
-		if (map)
+		if (map && cs->prioidx < map->priomap_len)
 			map->priomap[cs->prioidx] = 0;
 	}
 	rtnl_unlock();
@@ -166,7 +166,7 @@ static int read_priomap(struct cgroup *cont, struct cftype *cft,
 	rcu_read_lock();
 	for_each_netdev_rcu(&init_net, dev) {
 		map = rcu_dereference(dev->priomap);
-		priority = map ? map->priomap[prioidx] : 0;
+		priority = (map && prioidx < map->priomap_len) ? map->priomap[prioidx] : 0;
 		cb->fill(cb, dev->name, priority);
 	}
 	rcu_read_unlock();



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09  7:45 [PATCH] net: cgroup: fix out of bounds accesses Eric Dumazet
@ 2012-07-09  8:15 ` Gao feng
  2012-07-09 21:51   ` David Miller
  2012-07-09 11:01 ` Neil Horman
  1 sibling, 1 reply; 15+ messages in thread
From: Gao feng @ 2012-07-09  8:15 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, nhorman, linux-kernel, netdev, lizefan, tj

于 2012年07月09日 15:45, Eric Dumazet 写道:
> From: Eric Dumazet <edumazet@google.com>
> 
> dev->priomap is allocated by extend_netdev_table() called from
> update_netdev_tables().
> And this is only called if write_priomap() is called.
> 
> But if write_priomap() is not called, it seems we can have out of bounds
> accesses in cgrp_destroy(), read_priomap() & skb_update_prio()
> 
> With help from Gao Feng
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Gao feng <gaofeng@cn.fujitsu.com>
> ---
> net/core/dev.c            |    8 ++++++--
> net/core/netprio_cgroup.c |    4 ++--
> 2 files changed, 8 insertions(+), 4 deletions(-)

Acked-by: Gao feng <gaofeng@cn.fujitsu.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09  7:45 [PATCH] net: cgroup: fix out of bounds accesses Eric Dumazet
  2012-07-09  8:15 ` Gao feng
@ 2012-07-09 11:01 ` Neil Horman
  2012-07-09 11:50   ` Eric Dumazet
  1 sibling, 1 reply; 15+ messages in thread
From: Neil Horman @ 2012-07-09 11:01 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, linux-kernel, netdev, lizefan, tj, Gao feng

On Mon, Jul 09, 2012 at 09:45:10AM +0200, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> dev->priomap is allocated by extend_netdev_table() called from
> update_netdev_tables().
> And this is only called if write_priomap() is called.
> 
> But if write_priomap() is not called, it seems we can have out of bounds
> accesses in cgrp_destroy(), read_priomap() & skb_update_prio()
> 
> With help from Gao Feng
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Gao feng <gaofeng@cn.fujitsu.com>
> ---
> net/core/dev.c            |    8 ++++++--
> net/core/netprio_cgroup.c |    4 ++--
> 2 files changed, 8 insertions(+), 4 deletions(-)
> 

Thank you for doing this Eric, Gao.  Just to be sure (I asked in the previous
thread), would it be better to avoid the length check in skb_update_prio, and
instead update the netdev tables to be long enough in cgrp_create and in
netprio_device_event on device registration?

Neil


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09 11:01 ` Neil Horman
@ 2012-07-09 11:50   ` Eric Dumazet
  2012-07-09 12:13     ` Neil Horman
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Dumazet @ 2012-07-09 11:50 UTC (permalink / raw)
  To: Neil Horman; +Cc: David Miller, linux-kernel, netdev, lizefan, tj, Gao feng

On Mon, 2012-07-09 at 07:01 -0400, Neil Horman wrote:

> Thank you for doing this Eric, Gao.  Just to be sure (I asked in the previous
> thread), would it be better to avoid the length check in skb_update_prio, and
> instead update the netdev tables to be long enough in cgrp_create and in
> netprio_device_event on device registration?

Yes probably, and it is even needed because extend_netdev_table() can
acutally fail to expand the table if kzalloc() returned NULL.

Current code just ignores this allocation failure so we also can crash
in write_priomap()




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09 11:50   ` Eric Dumazet
@ 2012-07-09 12:13     ` Neil Horman
  2012-07-09 12:40       ` Eric Dumazet
  0 siblings, 1 reply; 15+ messages in thread
From: Neil Horman @ 2012-07-09 12:13 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, linux-kernel, netdev, lizefan, tj, Gao feng

On Mon, Jul 09, 2012 at 01:50:52PM +0200, Eric Dumazet wrote:
> On Mon, 2012-07-09 at 07:01 -0400, Neil Horman wrote:
> 
> > Thank you for doing this Eric, Gao.  Just to be sure (I asked in the previous
> > thread), would it be better to avoid the length check in skb_update_prio, and
> > instead update the netdev tables to be long enough in cgrp_create and in
> > netprio_device_event on device registration?
> 
> Yes probably, and it is even needed because extend_netdev_table() can
> acutally fail to expand the table if kzalloc() returned NULL.
> 
> Current code just ignores this allocation failure so we also can crash
> in write_priomap()
> 
ACK, can you follow up with a patch please?

Thanks!
Neil

> 
> 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09 12:13     ` Neil Horman
@ 2012-07-09 12:40       ` Eric Dumazet
  2012-07-09 12:56         ` Neil Horman
  2012-07-10  2:31         ` [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup Gao feng
  0 siblings, 2 replies; 15+ messages in thread
From: Eric Dumazet @ 2012-07-09 12:40 UTC (permalink / raw)
  To: Neil Horman; +Cc: David Miller, linux-kernel, netdev, lizefan, tj, Gao feng

On Mon, 2012-07-09 at 08:13 -0400, Neil Horman wrote:
> On Mon, Jul 09, 2012 at 01:50:52PM +0200, Eric Dumazet wrote:
> > On Mon, 2012-07-09 at 07:01 -0400, Neil Horman wrote:
> > 
> > > Thank you for doing this Eric, Gao.  Just to be sure (I asked in the previous
> > > thread), would it be better to avoid the length check in skb_update_prio, and
> > > instead update the netdev tables to be long enough in cgrp_create and in
> > > netprio_device_event on device registration?
> > 
> > Yes probably, and it is even needed because extend_netdev_table() can
> > acutally fail to expand the table if kzalloc() returned NULL.
> > 
> > Current code just ignores this allocation failure so we also can crash
> > in write_priomap()
> > 
> ACK, can you follow up with a patch please?

Gao was working on this allocation problem (he privately sent me a v1 of
his patch), so I think we can wait Gao submit a v2 to combine all the
work/ideas in a single patch.

(ie make sure we dont need additional bound checkings in fast path)




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09 12:40       ` Eric Dumazet
@ 2012-07-09 12:56         ` Neil Horman
  2012-07-10  2:31         ` [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup Gao feng
  1 sibling, 0 replies; 15+ messages in thread
From: Neil Horman @ 2012-07-09 12:56 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, linux-kernel, netdev, lizefan, tj, Gao feng

On Mon, Jul 09, 2012 at 02:40:25PM +0200, Eric Dumazet wrote:
> On Mon, 2012-07-09 at 08:13 -0400, Neil Horman wrote:
> > On Mon, Jul 09, 2012 at 01:50:52PM +0200, Eric Dumazet wrote:
> > > On Mon, 2012-07-09 at 07:01 -0400, Neil Horman wrote:
> > > 
> > > > Thank you for doing this Eric, Gao.  Just to be sure (I asked in the previous
> > > > thread), would it be better to avoid the length check in skb_update_prio, and
> > > > instead update the netdev tables to be long enough in cgrp_create and in
> > > > netprio_device_event on device registration?
> > > 
> > > Yes probably, and it is even needed because extend_netdev_table() can
> > > acutally fail to expand the table if kzalloc() returned NULL.
> > > 
> > > Current code just ignores this allocation failure so we also can crash
> > > in write_priomap()
> > > 
> > ACK, can you follow up with a patch please?
> 
> Gao was working on this allocation problem (he privately sent me a v1 of
> his patch), so I think we can wait Gao submit a v2 to combine all the
> work/ideas in a single patch.
> 
> (ie make sure we dont need additional bound checkings in fast path)
> 
> 
Ok, I agree.  thanks!
Neil

> 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09  8:15 ` Gao feng
@ 2012-07-09 21:51   ` David Miller
  2012-07-10  2:33     ` Gao feng
  0 siblings, 1 reply; 15+ messages in thread
From: David Miller @ 2012-07-09 21:51 UTC (permalink / raw)
  To: gaofeng; +Cc: eric.dumazet, nhorman, linux-kernel, netdev, lizefan, tj

From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Mon, 09 Jul 2012 16:15:29 +0800

> 于 2012年07月09日 15:45, Eric Dumazet 写道:
>> From: Eric Dumazet <edumazet@google.com>
>> 
>> dev->priomap is allocated by extend_netdev_table() called from
>> update_netdev_tables().
>> And this is only called if write_priomap() is called.
>> 
>> But if write_priomap() is not called, it seems we can have out of bounds
>> accesses in cgrp_destroy(), read_priomap() & skb_update_prio()
>> 
>> With help from Gao Feng
>> 
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
>> Cc: Neil Horman <nhorman@tuxdriver.com>
>> Cc: Gao feng <gaofeng@cn.fujitsu.com>
>> ---
>> net/core/dev.c            |    8 ++++++--
>> net/core/netprio_cgroup.c |    4 ++--
>> 2 files changed, 8 insertions(+), 4 deletions(-)
> 
> Acked-by: Gao feng <gaofeng@cn.fujitsu.com>

Applied.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup
  2012-07-09 12:40       ` Eric Dumazet
  2012-07-09 12:56         ` Neil Horman
@ 2012-07-10  2:31         ` Gao feng
  2012-07-10  4:14           ` Eric Dumazet
  1 sibling, 1 reply; 15+ messages in thread
From: Gao feng @ 2012-07-10  2:31 UTC (permalink / raw)
  To: eric.dumazet, nhorman
  Cc: davem, linux-kernel, netdev, lizefan, tj, Gao feng, Eric Dumazet

there are some out of bound accesses in netprio cgroup.
when creating a new netprio cgroup,we only set a prioidx for
the new cgroup,without allocate memory for dev->priomap.

because we don't want to see additional bound checkings in
fast path, so I think the best way is to allocate memory when we
creating a new netprio cgroup.

and because netdev can be created or registered after cgroup being
created, so extend_netdev_table is also needed in write_priomap.

this patch add a return value for update_netdev_tables & extend_netdev_table,
so when new_priomap is allocated failed,write_priomap will stop to access
the priomap,and return -ENOMEM back to the userspace to tell the user
what happend.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Eric Dumazet <edumazet@google.com>
---
 net/core/netprio_cgroup.c |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index aa907ed..3554f28 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -65,7 +65,7 @@ static void put_prioidx(u32 idx)
 	spin_unlock_irqrestore(&prioidx_map_lock, flags);
 }
 
-static void extend_netdev_table(struct net_device *dev, u32 new_len)
+static int extend_netdev_table(struct net_device *dev, u32 new_len)
 {
 	size_t new_size = sizeof(struct netprio_map) +
 			   ((sizeof(u32) * new_len));
@@ -77,7 +77,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
 
 	if (!new_priomap) {
 		pr_warn("Unable to alloc new priomap!\n");
-		return;
+		return -ENOMEM;
 	}
 
 	for (i = 0;
@@ -90,10 +90,12 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
 	rcu_assign_pointer(dev->priomap, new_priomap);
 	if (old_priomap)
 		kfree_rcu(old_priomap, rcu);
+	return 0;
 }
 
-static void update_netdev_tables(void)
+static int update_netdev_tables(void)
 {
+	int ret = 0;
 	struct net_device *dev;
 	u32 max_len = atomic_read(&max_prioidx) + 1;
 	struct netprio_map *map;
@@ -102,34 +104,44 @@ static void update_netdev_tables(void)
 	for_each_netdev(&init_net, dev) {
 		map = rtnl_dereference(dev->priomap);
 		if ((!map) ||
-		    (map->priomap_len < max_len))
-			extend_netdev_table(dev, max_len);
+		    (map->priomap_len < max_len)) {
+			ret = extend_netdev_table(dev, max_len);
+			if (ret < 0)
+				break;
+		}
 	}
 	rtnl_unlock();
+	return ret;
 }
 
 static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
 {
 	struct cgroup_netprio_state *cs;
-	int ret;
+	int ret = -EINVAL;
 
 	cs = kzalloc(sizeof(*cs), GFP_KERNEL);
 	if (!cs)
 		return ERR_PTR(-ENOMEM);
 
-	if (cgrp->parent && cgrp_netprio_state(cgrp->parent)->prioidx) {
-		kfree(cs);
-		return ERR_PTR(-EINVAL);
-	}
+	if (cgrp->parent && cgrp_netprio_state(cgrp->parent)->prioidx)
+		goto out;
 
 	ret = get_prioidx(&cs->prioidx);
-	if (ret != 0) {
+	if (ret < 0) {
 		pr_warn("No space in priority index array\n");
-		kfree(cs);
-		return ERR_PTR(ret);
+		goto out;
+	}
+
+	ret = update_netdev_tables();
+	if (ret < 0) {
+		put_prioidx(cs->prioidx);
+		goto out;
 	}
 
 	return &cs->css;
+out:
+	kfree(cs);
+	return ERR_PTR(ret);
 }
 
 static void cgrp_destroy(struct cgroup *cgrp)
@@ -221,7 +233,10 @@ static int write_priomap(struct cgroup *cgrp, struct cftype *cft,
 	if (!dev)
 		goto out_free_devname;
 
-	update_netdev_tables();
+	ret = update_netdev_tables();
+	if (ret < 0)
+		goto out_free_devname;
+
 	ret = 0;
 	rcu_read_lock();
 	map = rcu_dereference(dev->priomap);
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-09 21:51   ` David Miller
@ 2012-07-10  2:33     ` Gao feng
  2012-07-10  2:37       ` David Miller
  0 siblings, 1 reply; 15+ messages in thread
From: Gao feng @ 2012-07-10  2:33 UTC (permalink / raw)
  To: David Miller; +Cc: eric.dumazet, nhorman, linux-kernel, netdev, lizefan, tj

于 2012年07月10日 05:51, David Miller 写道:
> From: Gao feng <gaofeng@cn.fujitsu.com>
> Date: Mon, 09 Jul 2012 16:15:29 +0800
> 
>> 于 2012年07月09日 15:45, Eric Dumazet 写道:
>>> From: Eric Dumazet <edumazet@google.com>
>>>
>>> dev->priomap is allocated by extend_netdev_table() called from
>>> update_netdev_tables().
>>> And this is only called if write_priomap() is called.
>>>
>>> But if write_priomap() is not called, it seems we can have out of bounds
>>> accesses in cgrp_destroy(), read_priomap() & skb_update_prio()
>>>
>>> With help from Gao Feng
>>>
>>> Signed-off-by: Eric Dumazet <edumazet@google.com>
>>> Cc: Neil Horman <nhorman@tuxdriver.com>
>>> Cc: Gao feng <gaofeng@cn.fujitsu.com>
>>> ---
>>> net/core/dev.c            |    8 ++++++--
>>> net/core/netprio_cgroup.c |    4 ++--
>>> 2 files changed, 8 insertions(+), 4 deletions(-)
>>
>> Acked-by: Gao feng <gaofeng@cn.fujitsu.com>
> 
> Applied.
> 

Hi David

Please see my patch in this thread, I think it's a better way to fix this bug.

Thanks.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix out of bounds accesses
  2012-07-10  2:33     ` Gao feng
@ 2012-07-10  2:37       ` David Miller
  0 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2012-07-10  2:37 UTC (permalink / raw)
  To: gaofeng; +Cc: eric.dumazet, nhorman, linux-kernel, netdev, lizefan, tj

From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Tue, 10 Jul 2012 10:33:23 +0800

> Please see my patch in this thread, I think it's a better way to fix this bug.

You'll need to work that out with Eric, fwiw I think his patch was
clean and just fine and it's staying in my tree.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup
  2012-07-10  2:31         ` [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup Gao feng
@ 2012-07-10  4:14           ` Eric Dumazet
  2012-07-10  8:53             ` Gao feng
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Dumazet @ 2012-07-10  4:14 UTC (permalink / raw)
  To: Gao feng; +Cc: nhorman, davem, linux-kernel, netdev, lizefan, tj, Eric Dumazet

On Tue, 2012-07-10 at 10:31 +0800, Gao feng wrote:
> there are some out of bound accesses in netprio cgroup.
> when creating a new netprio cgroup,we only set a prioidx for
> the new cgroup,without allocate memory for dev->priomap.
> 
> because we don't want to see additional bound checkings in
> fast path, so I think the best way is to allocate memory when we
> creating a new netprio cgroup.
> 
> and because netdev can be created or registered after cgroup being
> created, so extend_netdev_table is also needed in write_priomap.
> 
> this patch add a return value for update_netdev_tables & extend_netdev_table,
> so when new_priomap is allocated failed,write_priomap will stop to access
> the priomap,and return -ENOMEM back to the userspace to tell the user
> what happend.
> 
> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: Eric Dumazet <edumazet@google.com>
> ---

>  static void cgrp_destroy(struct cgroup *cgrp)
> @@ -221,7 +233,10 @@ static int write_priomap(struct cgroup *cgrp, struct cftype *cft,
>  	if (!dev)
>  		goto out_free_devname;
>  
> -	update_netdev_tables();
> +	ret = update_netdev_tables();
> +	if (ret < 0)
> +		goto out_free_devname;
> +
>  	ret = 0;
>  	rcu_read_lock();
>  	map = rcu_dereference(dev->priomap);

Hi Gao

Is it still needed to call update_netdev_tables() from write_priomap() ?




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup
  2012-07-10  4:14           ` Eric Dumazet
@ 2012-07-10  8:53             ` Gao feng
  2012-07-10  9:15               ` Eric Dumazet
  0 siblings, 1 reply; 15+ messages in thread
From: Gao feng @ 2012-07-10  8:53 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: nhorman, davem, linux-kernel, netdev, lizefan, tj, Eric Dumazet


> Hi Gao
> 
> Is it still needed to call update_netdev_tables() from write_priomap() ?
> 

Yes, I think it's needed,because read_priomap will show all of the net devices,

But we may add the netdev after create a netprio cgroup, so the new added netdev's
priomap will not be allocated. if we don't call update_netdev_tables in write_priomap,
we may access this unallocated memory.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup
  2012-07-10  8:53             ` Gao feng
@ 2012-07-10  9:15               ` Eric Dumazet
  2012-07-10  9:36                 ` Gao feng
  0 siblings, 1 reply; 15+ messages in thread
From: Eric Dumazet @ 2012-07-10  9:15 UTC (permalink / raw)
  To: Gao feng; +Cc: nhorman, davem, linux-kernel, netdev, lizefan, tj, Eric Dumazet

On Tue, 2012-07-10 at 16:53 +0800, Gao feng wrote:
> > Hi Gao
> > 
> > Is it still needed to call update_netdev_tables() from write_priomap() ?
> > 
> 
> Yes, I think it's needed,because read_priomap will show all of the net devices,
> 
> But we may add the netdev after create a netprio cgroup, so the new added netdev's
> priomap will not be allocated. if we don't call update_netdev_tables in write_priomap,
> we may access this unallocated memory.
> 

I realize my question was not clear.

If we write in write_priomap() a field of a single netdevice,
why should we allocate memory for all netdevices on the machine ?

So the question was : Do we really need to call
update_netdev_tables(alldevs), instead of extend_netdev_table(dev)




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup
  2012-07-10  9:15               ` Eric Dumazet
@ 2012-07-10  9:36                 ` Gao feng
  0 siblings, 0 replies; 15+ messages in thread
From: Gao feng @ 2012-07-10  9:36 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: nhorman, davem, linux-kernel, netdev, lizefan, tj, Eric Dumazet

于 2012年07月10日 17:15, Eric Dumazet 写道:
> On Tue, 2012-07-10 at 16:53 +0800, Gao feng wrote:
>>> Hi Gao
>>>
>>> Is it still needed to call update_netdev_tables() from write_priomap() ?
>>>
>>
>> Yes, I think it's needed,because read_priomap will show all of the net devices,
>>
>> But we may add the netdev after create a netprio cgroup, so the new added netdev's
>> priomap will not be allocated. if we don't call update_netdev_tables in write_priomap,
>> we may access this unallocated memory.
>>
> 
> I realize my question was not clear.
> 
> If we write in write_priomap() a field of a single netdevice,
> why should we allocate memory for all netdevices on the machine ?
> 
> So the question was : Do we really need to call
> update_netdev_tables(alldevs), instead of extend_netdev_table(dev)
> 
> 

I get it.

You are right,Indeed we only need to call extend_netdev_table
for the netdev witch we want to change.

and I read the commit f5c38208d32412d72b97a4f0d44af0eb39feb20b,
found why we need delay allocation.

I will send a v2 patch.

Thanks!

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-07-10  9:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-09  7:45 [PATCH] net: cgroup: fix out of bounds accesses Eric Dumazet
2012-07-09  8:15 ` Gao feng
2012-07-09 21:51   ` David Miller
2012-07-10  2:33     ` Gao feng
2012-07-10  2:37       ` David Miller
2012-07-09 11:01 ` Neil Horman
2012-07-09 11:50   ` Eric Dumazet
2012-07-09 12:13     ` Neil Horman
2012-07-09 12:40       ` Eric Dumazet
2012-07-09 12:56         ` Neil Horman
2012-07-10  2:31         ` [PATCH] net: cgroup: fix access the unallocated memory in netprio cgroup Gao feng
2012-07-10  4:14           ` Eric Dumazet
2012-07-10  8:53             ` Gao feng
2012-07-10  9:15               ` Eric Dumazet
2012-07-10  9:36                 ` Gao feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.