2013-04-11 21:25:09

by Steven Rostedt

[permalink] [raw]
Subject: [ 163/171 ] ipv6: fix bad free of addrconf_init_net

3.6.11.2 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Hong Zhiguo <[email protected]>

[ Upstream commit a79ca223e029aa4f09abb337accf1812c900a800 ]

Signed-off-by: Hong Zhiguo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
net/ipv6/addrconf.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index fd82a30..ec627b5 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4653,26 +4653,20 @@ static void addrconf_sysctl_unregister(struct inet6_dev *idev)

static int __net_init addrconf_init_net(struct net *net)
{
- int err;
+ int err = -ENOMEM;
struct ipv6_devconf *all, *dflt;

- err = -ENOMEM;
- all = &ipv6_devconf;
- dflt = &ipv6_devconf_dflt;
+ all = kmemdup(&ipv6_devconf, sizeof(ipv6_devconf), GFP_KERNEL);
+ if (all == NULL)
+ goto err_alloc_all;

- if (!net_eq(net, &init_net)) {
- all = kmemdup(all, sizeof(ipv6_devconf), GFP_KERNEL);
- if (all == NULL)
- goto err_alloc_all;
+ dflt = kmemdup(&ipv6_devconf_dflt, sizeof(ipv6_devconf_dflt), GFP_KERNEL);
+ if (dflt == NULL)
+ goto err_alloc_dflt;

- dflt = kmemdup(dflt, sizeof(ipv6_devconf_dflt), GFP_KERNEL);
- if (dflt == NULL)
- goto err_alloc_dflt;
- } else {
- /* these will be inherited by all namespaces */
- dflt->autoconf = ipv6_defaults.autoconf;
- dflt->disable_ipv6 = ipv6_defaults.disable_ipv6;
- }
+ /* these will be inherited by all namespaces */
+ dflt->autoconf = ipv6_defaults.autoconf;
+ dflt->disable_ipv6 = ipv6_defaults.disable_ipv6;

net->ipv6.devconf_all = all;
net->ipv6.devconf_dflt = dflt;
--
1.7.10.4


2013-09-24 06:36:47

by Zhu Yanjun

[permalink] [raw]
Subject: Re: [ 163/171 ] ipv6: fix bad free of addrconf_init_net

On 04/12/2013 04:27 AM, Steven Rostedt wrote:
On linux with stable kernel v3.4.39, when this patch (ipv6: fix bad free
of addrconf_init_net) is applied. Then I run the following commands:

1. the default value of ipv6 forwarding is 0

2. we change it to 1 firstly via:
# vi /etc/sysctl.conf
Uncomment: net.ipv6.conf.all.forwarding=1
#sysctl ?p
Then we can verify via
#sysctl ?a | grep forwarding

3, then we create a new namespace via:
# ip netns add fib_100
# ip netns exec fib_100 sysctl -a | grep forwarding

We?ll see in this new name space, the value of ipv6 forwarding will be
set to ?1? in v3.4.38, but in v3.4.39, the value is still be ?0?

without this patch (ipv6: fix bad free of addrconf_init_net), the value
of ipv6 forwarding will be set to ?1?.

Would you like to tell me which one (v4.3.39 and v4.3.38) is correct?

Best Regards!
Zhu Yanjun