From patchwork Thu May 8 07:40:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangweidong X-Patchwork-Id: 346915 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DF2731415A4 for ; Thu, 8 May 2014 17:42:08 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753315AbaEHHmD (ORCPT ); Thu, 8 May 2014 03:42:03 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:12061 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751991AbaEHHln (ORCPT ); Thu, 8 May 2014 03:41:43 -0400 Received: from 172.24.2.119 (EHLO szxeml208-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BVE98318; Thu, 08 May 2014 15:41:20 +0800 (CST) Received: from SZXEML448-HUB.china.huawei.com (10.82.67.191) by szxeml208-edg.china.huawei.com (172.24.2.57) with Microsoft SMTP Server (TLS) id 14.3.158.1; Thu, 8 May 2014 15:40:46 +0800 Received: from [127.0.0.1] (10.177.18.75) by szxeml448-hub.china.huawei.com (10.82.67.191) with Microsoft SMTP Server id 14.3.158.1; Thu, 8 May 2014 15:40:46 +0800 Message-ID: <536B34FD.8030601@huawei.com> Date: Thu, 8 May 2014 15:40:45 +0800 From: Wang Weidong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: David Miller , , , , CC: Subject: [PATCH net-next] ipv4: fix kfree static array pointer in ipv4_sysctl_exit_net X-Originating-IP: [10.177.18.75] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In ipv4_sysctl_init_net, we don't kmemdup a sysctl_table for init_net, so init_net->ipv4.ipv4_hdr->ctl_table_arg points to ipv4_net_table which is a static array pointer. So when do ipv4_sysctl_exit_net, it will free the ipv4_net_table for init_net. So add a check net_namespace init_net before kfree the sysctl_table. Signed-off-by: Wang Weidong --- net/ipv4/sysctl_net_ipv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 44eba05..2825577 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -891,7 +891,8 @@ static __net_exit void ipv4_sysctl_exit_net(struct net *net) table = net->ipv4.ipv4_hdr->ctl_table_arg; unregister_net_sysctl_table(net->ipv4.ipv4_hdr); - kfree(table); + if (!net_eq(net, &init_net)) + kfree(table); } static __net_initdata struct pernet_operations ipv4_sysctl_ops = {