On Tue, Jan 24, 2012 at 5:27 PM, Sjur Brændeland
[off-list ref] wrote:
net_generic() calls BUG_ON() if called with uninitialized
network name-space. Add check if net is initialized before
calling net_generic(). This fixes the following oops:
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
Signed-off-by: Sjur Brændeland <redacted>
---
Hi Sasha,
Do you have any chance to review and test this patch?
I'd like to get the net namespace handling this right this time ...
Thanks,
Sjur
net_generic() calls BUG_ON() if called with uninitialized
network name-space. Add check if net is initialized before
calling net_generic(). This fixes the following oops:
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
Signed-off-by: Sjur Brændeland <redacted>
Tested-by: Sasha Levin <redacted>
---
Hi Sasha and Dave,
[Sasha]
Works for me.
Thank you Sasha for reporting this bug and testing my patch,
I appreciate it.
[Dave]
Please post all networking patches CC:'d
Sorry, I missed the obvious.
I'm resending the same patch as yesterday, this time to:netdev
and with "Tested-by: Sasha". Please apply to net.
Thanks,
Sjur
net/caif/caif_dev.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
From: Eric Dumazet <hidden> Date: 2012-01-26 06:14:44
Le mercredi 25 janvier 2012 à 21:33 +0100, Sjur Brændeland a écrit :
quoted hunk
net_generic() calls BUG_ON() if called with uninitialized
network name-space. Add check if net is initialized before
calling net_generic(). This fixes the following oops:
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
Signed-off-by: Sjur Brændeland <redacted>
Tested-by: Sasha Levin <redacted>
---
Hi Sasha and Dave,
[Sasha]
quoted
Works for me.
Thank you Sasha for reporting this bug and testing my patch,
I appreciate it.
[Dave]
quoted
Please post all networking patches CC:'d
Sorry, I missed the obvious.
I'm resending the same patch as yesterday, this time to:netdev
and with "Tested-by: Sasha". Please apply to net.
Thanks,
Sjur
net/caif/caif_dev.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
From: Eric Dumazet <hidden> Date: 2012-01-26 10:41:44
Le mercredi 25 janvier 2012 à 21:33 +0100, Sjur Brændeland a écrit :
quoted hunk
net_generic() calls BUG_ON() if called with uninitialized
network name-space. Add check if net is initialized before
calling net_generic(). This fixes the following oops:
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
Signed-off-by: Sjur Brændeland <redacted>
Tested-by: Sasha Levin <redacted>
---
Hi Sasha and Dave,
[Sasha]
quoted
Works for me.
Thank you Sasha for reporting this bug and testing my patch,
I appreciate it.
[Dave]
quoted
Please post all networking patches CC:'d
Sorry, I missed the obvious.
I'm resending the same patch as yesterday, this time to:netdev
and with "Tested-by: Sasha". Please apply to net.
Thanks,
Sjur
net/caif/caif_dev.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
@@ -371,6 +371,14 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,structcflayer*layer,*link_support;inthead_room=0;structcaif_device_entry_list*caifdevs;+intlen;++rcu_read_lock();+len=rcu_dereference(dev_net(dev)->gen)->len;+rcu_read_unlock();++if(caif_net_id==0||caif_net_id>len)+return0;cfg=get_cfcnfg(dev_net(dev));caifdevs=caif_device_list(dev_net(dev));
I believe the problem is in net_namespace infrastructure, not in CAIF.
Could you test following patch instead ?
[PATCH] netns: fix net_alloc_generic()
When a new net namespace is created, we should attach to it a "struct
net_generic" with enough slots (even empty), or we can hit the following
BUG_ON() :
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
net_alloc_generic() should take into account the maximum index into the
ptr array, as a subsystem might use net_generic() anytime.
This also reduces number of reallocations in net_assign_generic()
Reported-by: Sasha Levin <redacted>
Signed-off-by: Eric Dumazet <redacted>
Cc: Sjur Brændeland <redacted>
Cc: Eric W. Biederman <redacted>
Cc: Pavel Emelyanov <redacted>
---
net/core/net_namespace.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
@@ -30,6 +30,20 @@ EXPORT_SYMBOL(init_net);#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */+staticunsignedintmax_gen_ptrs=INITIAL_NET_GEN_PTRS;++staticstructnet_generic*net_alloc_generic(void)+{+structnet_generic*ng;+size_tgeneric_size=offsetof(structnet_generic,ptr[max_gen_ptrs]);++ng=kzalloc(generic_size,GFP_KERNEL);+if(ng)+ng->len=max_gen_ptrs;++returnng;+}+staticintnet_assign_generic(structnet*net,intid,void*data){structnet_generic*ng,*old_ng;
@@ -43,8 +57,7 @@ static int net_assign_generic(struct net *net, int id, void *data)if(old_ng->len>=id)gotoassign;-ng=kzalloc(sizeof(structnet_generic)+-id*sizeof(void*),GFP_KERNEL);+ng=net_alloc_generic();if(ng==NULL)return-ENOMEM;
@@ -59,7 +72,6 @@ static int net_assign_generic(struct net *net, int id, void *data)*theoldcopyforkfreeafteragraceperiod.*/-ng->len=id;memcpy(&ng->ptr,&old_ng->ptr,old_ng->len*sizeof(void*));rcu_assign_pointer(net->gen,ng);
From: Pavel Emelyanov <hidden> Date: 2012-01-26 10:45:06
I believe the problem is in net_namespace infrastructure, not in CAIF.
Could you test following patch instead ?
[PATCH] netns: fix net_alloc_generic()
When a new net namespace is created, we should attach to it a "struct
net_generic" with enough slots (even empty), or we can hit the following
BUG_ON() :
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
net_alloc_generic() should take into account the maximum index into the
ptr array, as a subsystem might use net_generic() anytime.
I'm not sure I understand it correctly, but subsystem can only use the
net_generic() only (!) after the net_assign_generic() is performed.
quoted hunk
This also reduces number of reallocations in net_assign_generic()
Reported-by: Sasha Levin <redacted>
Signed-off-by: Eric Dumazet <redacted>
Cc: Sjur Brændeland <redacted>
Cc: Eric W. Biederman <redacted>
Cc: Pavel Emelyanov <redacted>
---
net/core/net_namespace.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
@@ -30,6 +30,20 @@ EXPORT_SYMBOL(init_net);#define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */+staticunsignedintmax_gen_ptrs=INITIAL_NET_GEN_PTRS;++staticstructnet_generic*net_alloc_generic(void)+{+structnet_generic*ng;+size_tgeneric_size=offsetof(structnet_generic,ptr[max_gen_ptrs]);++ng=kzalloc(generic_size,GFP_KERNEL);+if(ng)+ng->len=max_gen_ptrs;++returnng;+}+staticintnet_assign_generic(structnet*net,intid,void*data){structnet_generic*ng,*old_ng;
@@ -43,8 +57,7 @@ static int net_assign_generic(struct net *net, int id, void *data)if(old_ng->len>=id)gotoassign;-ng=kzalloc(sizeof(structnet_generic)+-id*sizeof(void*),GFP_KERNEL);+ng=net_alloc_generic();if(ng==NULL)return-ENOMEM;
@@ -59,7 +72,6 @@ static int net_assign_generic(struct net *net, int id, void *data)*theoldcopyforkfreeafteragraceperiod.*/-ng->len=id;memcpy(&ng->ptr,&old_ng->ptr,old_ng->len*sizeof(void*));rcu_assign_pointer(net->gen,ng);
From: Eric Dumazet <hidden> Date: 2012-01-26 10:51:54
Le jeudi 26 janvier 2012 à 14:44 +0400, Pavel Emelyanov a écrit :
quoted
I believe the problem is in net_namespace infrastructure, not in CAIF.
Could you test following patch instead ?
[PATCH] netns: fix net_alloc_generic()
When a new net namespace is created, we should attach to it a "struct
net_generic" with enough slots (even empty), or we can hit the following
BUG_ON() :
[ 200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[ 200.752016] [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[ 200.752016] [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[ 200.752016] [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[ 200.752016] [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[ 200.752016] [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[ 200.752016] [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[ 200.752016] [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[ 200.752016] [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[ 200.752016] [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[ 200.752016] [<ffffffff821b5e62>] ops_init+0x42/0x180
[ 200.752016] [<ffffffff821b600b>] setup_net+0x6b/0x100
[ 200.752016] [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[ 200.752016] [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190
net_alloc_generic() should take into account the maximum index into the
ptr array, as a subsystem might use net_generic() anytime.
I'm not sure I understand it correctly, but subsystem can only use the
net_generic() only (!) after the net_assign_generic() is performed.
Yes, but here, loopback_net_init() calls register_netdev()
So every subsystems _notify are called, even if subsystem _init_net()
was not yet called.
Its a chicken and egg problem.
From: David Miller <davem@davemloft.net> Date: 2012-01-26 18:37:34
From: Eric Dumazet <redacted>
Date: Thu, 26 Jan 2012 11:41:38 +0100
[PATCH] netns: fix net_alloc_generic()
When a new net namespace is created, we should attach to it a "struct
net_generic" with enough slots (even empty), or we can hit the following
BUG_ON() :
...
net_alloc_generic() should take into account the maximum index into the
ptr array, as a subsystem might use net_generic() anytime.
This also reduces number of reallocations in net_assign_generic()
Reported-by: Sasha Levin <redacted>
Signed-off-by: Eric Dumazet <redacted>