From patchwork Wed Sep 21 21:02:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 673054 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sfXDf3Fzpz9svs for ; Thu, 22 Sep 2016 07:04:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934247AbcIUVDj (ORCPT ); Wed, 21 Sep 2016 17:03:39 -0400 Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:40528 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933320AbcIUVDi (ORCPT ); Wed, 21 Sep 2016 17:03:38 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.84_2) (envelope-from ) id 1bmofN-0007h4-9l; Wed, 21 Sep 2016 23:02:53 +0200 Date: Wed, 21 Sep 2016 23:02:53 +0200 From: Florian Westphal To: Fabian Frederick Cc: Florian Westphal , Eric Dumazet , Pablo Neira Ayuso , linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org Subject: Re: [PATCH 1/1 linux-next] netfilter: conntrack: fix kmemleak false positive Message-ID: <20160921210253.GB24153@breakpoint.cc> References: <1474487397-11032-1-git-send-email-fabf@skynet.be> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1474487397-11032-1-git-send-email-fabf@skynet.be> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Fabian Frederick wrote: > Since commit f330a7fdbe16 > ("netfilter: conntrack: get rid of conntrack timer") > > closed connections remain longer in /proc/net/nf_conntrack > > Running current kernel; just after boot: > cat /proc/net/nf_conntrack | wc -l = 5 > 4 minutes required to clean up the table. We should reap the stale entries while iterating, just like we do for ctnetlink interface. Can you try this patch? > Going back to kernel version before commit above there are > no connections after some seconds. > > Referring to the commit changelog this was an expected behaviour but > it results in temporary kmemleak reports: I don't see kmemleak complaints on my test vm, I'm reluctant to turn it off. Can you explain why we see such 'false positive'? The conntracks should still be referenced, as they are in main table. > unreferenced object 0xffff88003b0e6600 (size 248): > comm "rsyslogd", pid 1595, jiffies 4294741312 (age 7.343s) > ... > backtrace: > [] kmemleak_alloc+0x23/0x40 > [] kmem_cache_alloc+0xd9/0x180 > [] __nf_conntrack_alloc.isra.50+0x48/0x170 > [] nf_conntrack_in+0x3a2/0x5f0 > [] ipv4_conntrack_local+0x40/0x50 > [] nf_iterate+0x5d/0x70 > [] nf_hook_slow+0x5f/0xb0 > [] __ip_local_out+0xad/0xe0 > [] ip_local_out+0x17/0x40 > [] ip_send_skb+0x14/0x40 > [] udp_send_skb+0x91/0x260 > [] udp_sendmsg+0x2f5/0x950 > [] inet_sendmsg+0x60/0x90 > [] sock_sendmsg+0x33/0x40 > [] SYSC_sendto+0xee/0x160 > [] SyS_sendto+0x9/0x10 > > (248 bytes being an nf_conn structure) > > Those structures being cleared in gc_worker() later on we can't talk > about unreferenced object so this patch uses kmemleak_not_leak() to > prevent those warnings. If thats the case, why is kmemleak complaining? Are you sure this is a false positive? --- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -212,6 +212,11 @@ static int ct_seq_show(struct seq_file *s, void *v) if (unlikely(!atomic_inc_not_zero(&ct->ct_general.use))) return 0; + if (nf_ct_should_gc(ct)) { + nf_ct_kill(ct); + goto release; + } + /* we only want to print DIR_ORIGINAL */ if (NF_CT_DIRECTION(hash)) goto release;