From patchwork Sun Jul 24 02:31:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 652065 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 3rxpMH4ptXz9sRZ for ; Sun, 24 Jul 2016 12:32:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751869AbcGXCby (ORCPT ); Sat, 23 Jul 2016 22:31:54 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:29078 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676AbcGXCbv (ORCPT ); Sat, 23 Jul 2016 22:31:51 -0400 Received: from fsav408.sakura.ne.jp (fsav408.sakura.ne.jp [133.242.250.107]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id u6O2Vhda055192; Sun, 24 Jul 2016 11:31:43 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav408.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav408.sakura.ne.jp); Sun, 24 Jul 2016 11:31:43 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav408.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank126074139022.bbtec.net [126.74.139.22]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id u6O2Vd8i055186 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 24 Jul 2016 11:31:43 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: pablo@netfilter.org Cc: netdev@vger.kernel.org, Tetsuo Handa Subject: [PATCH] netfilter: x_tables: fix kmemcheck warning. Date: Sun, 24 Jul 2016 11:31:15 +0900 Message-Id: <1469327475-9028-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org kmemcheck complains that some of struct nf_hook_ops members allocated at xt_hook_ops_alloc() are not initialized before nf_register_net_hook() is called. Add __GFP_ZERO to initialize explicitly. [ 367.411936] nf_conntrack version 0.5.0 (6144 buckets, 24576 max) [ 367.458540] ip_tables: (C) 2000-2006 Netfilter Core Team [ 367.463977] WARNING: kmemcheck: Caught 64-bit read from uninitialized memory (ffff88003af7f300) [ 367.465633] 00000000000000000000000000000000303f5381ffffffff0000000000000000 [ 367.468185] u u u u u u u u u u u u u u u u i i i i i i i i u u u u u u u u [ 367.470687] ^ [ 367.471079] RIP: 0010:[] [] nf_register_net_hook+0x2f/0x160 [ 367.472846] RSP: 0018:ffff88003f5abcb0 EFLAGS: 00010286 [ 367.473821] RAX: ffff88003adb73c0 RBX: ffff88003af7f300 RCX: 0000000000000000 [ 367.475122] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff88003adb7400 [ 367.476485] RBP: ffff88003f5abcc8 R08: 0000000000000067 R09: 0000000000000000 [ 367.477764] R10: ffff88003adb83c0 R11: 0000000000000000 R12: ffffffff81876760 [ 367.479053] R13: ffff88003adb73c0 R14: 0000000000000003 R15: ffff88003af7f300 [ 367.480351] FS: 0000000000000000(0000) GS:ffffffff8182c000(0000) knlGS:0000000000000000 [ 367.482018] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 367.483069] CR2: ffff88003f404280 CR3: 000000003ad30000 CR4: 00000000001406f0 [ 367.484357] [] nf_register_net_hooks+0x3c/0xa0 [ 367.485617] [] ipt_register_table+0xef/0x130 [ 367.486765] [] iptable_filter_table_init.part.1+0x51/0x70 [ 367.488125] [] iptable_filter_net_init+0x2a/0x30 [ 367.489375] [] ops_init+0x3c/0x130 [ 367.490410] [] register_pernet_operations+0x108/0x1c0 [ 367.491746] [] register_pernet_subsys+0x23/0x40 [ 367.492933] [] iptable_filter_init+0x33/0x4b [ 367.494053] [] do_one_initcall+0x4a/0x180 [ 367.495168] [] kernel_init_freeable+0x15b/0x201 [ 367.496332] [] kernel_init+0x9/0x100 [ 367.497369] [] ret_from_fork+0x1f/0x40 [ 367.498449] [] 0xffffffffffffffff [ 367.499523] Initializing XFRM netlink socket [ 367.500404] NET: Registered protocol family 10 [ 367.501792] ip6_tables: (C) 2000-2006 Netfilter Core Team [ 367.502971] NET: Registered protocol family 17 Signed-off-by: Tetsuo Handa --- net/netfilter/x_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index e0aa7c1..fc261fe 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1513,7 +1513,7 @@ xt_hook_ops_alloc(const struct xt_table *table, nf_hookfn *fn) if (!num_hooks) return ERR_PTR(-EINVAL); - ops = kmalloc(sizeof(*ops) * num_hooks, GFP_KERNEL); + ops = kmalloc(sizeof(*ops) * num_hooks, GFP_KERNEL | __GFP_ZERO); if (ops == NULL) return ERR_PTR(-ENOMEM);