Return-Path: Received: from imap1.codethink.co.uk ([176.9.8.82]:58755 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753685AbeDJPOM (ORCPT ); Tue, 10 Apr 2018 11:14:12 -0400 Message-ID: <1523373245.2654.182.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 38/97] netfilter: xt_CT: fix refcnt leak on error path From: Ben Hutchings To: Gao Feng , Liping Zhang , Pablo Neira Ayuso Cc: stable@vger.kernel.org, Sasha Levin , Greg Kroah-Hartman , LKML Date: Tue, 10 Apr 2018 16:14:05 +0100 In-Reply-To: <1522777564.2654.115.camel@codethink.co.uk> References: <20180323094157.535925724@linuxfoundation.org> <20180323094159.781131756@linuxfoundation.org> <1522777564.2654.115.camel@codethink.co.uk> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: On Tue, 2018-04-03 at 18:46 +0100, Ben Hutchings wrote: > On Fri, 2018-03-23 at 10:54 +0100, Greg Kroah-Hartman wrote: > > 4.4-stable review patch.  If anyone has any objections, please let me know. > > > > ------------------ > > > > From: Gao Feng > > > > > > [ Upstream commit 470acf55a021713869b9bcc967268ac90c8a0fac ] [...]  > > @@ -249,7 +252,7 @@ static int xt_ct_tg_check(const struct x > >   if (info->timeout[0]) { > >   ret = xt_ct_set_timeout(ct, par, info->timeout); > >   if (ret < 0) > > - goto err3; > > + goto err4; > >   } > >   __set_bit(IPS_CONFIRMED_BIT, &ct->status); > >   nf_conntrack_get(&ct->ct_general); > > @@ -257,6 +260,10 @@ out: > >   info->ct = ct; > >   return 0; > >   > > +err4: > > + help = nfct_help(ct); > > + if (help) > > + module_put(help->helper->me); > >  err3: > >   nf_ct_tmpl_free(ct); > >  err2: > > This does not.  nf_ct_tmpl_free() calls nf_ct_ext_destroy() which I > think will call back into xt_ct_tg_destroy().  So I think the module > reference is already dropped here and we mustn't do it twice.  Am I > missing something? I still don't understand this code, but I have verified that the module_put() is needed on this error path to balance the module reference count. I.e. this fix is good. Ben. -- Ben Hutchings Software Developer, Codethink Ltd.