Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755859AbYGXNev (ORCPT ); Thu, 24 Jul 2008 09:34:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752250AbYGXNel (ORCPT ); Thu, 24 Jul 2008 09:34:41 -0400 Received: from courier.cs.helsinki.fi ([128.214.9.1]:41384 "EHLO mail.cs.helsinki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbYGXNek (ORCPT ); Thu, 24 Jul 2008 09:34:40 -0400 Subject: Re: [regression] nf_iterate(), BUG: unable to handle kernel NULL pointer dereference From: Pekka Enberg To: Patrick McHardy Cc: Ingo Molnar , David Miller , herbert@gondor.apana.org.au, w@1wt.eu, davidn@davidnewall.com, torvalds@linux-foundation.org, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stefanr@s5r6.in-berlin.de, rjw@sisk.pl, ilpo.jarvinen@helsinki.fi, Dave Jones In-Reply-To: <48888434.3030207@trash.net> References: <20080724060448.GA10203@elte.hu> <20080724.022259.113079007.davem@davemloft.net> <20080724093411.GA12001@elte.hu> <20080724115625.GA23994@elte.hu> <20080724115957.GA25701@elte.hu> <48886FA6.6050908@trash.net> <84144f020807240544q507e1b7cv220d1afbae0ee0f0@mail.gmail.com> <48887A71.5010209@trash.net> <1216905812.5897.6.camel@penberg-laptop> <48888434.3030207@trash.net> Date: Thu, 24 Jul 2008 16:34:36 +0300 Message-Id: <1216906476.12021.4.camel@penberg-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Mailer: Evolution 2.22.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1893 Lines: 48 On Thu, 2008-07-24 at 15:31 +0200, Patrick McHardy wrote: > Pekka Enberg wrote: > > On Thu, 2008-07-24 at 14:49 +0200, Patrick McHardy wrote: > >> Pekka Enberg wrote: > >>> Hmm, why do you think it's related? It looks like elem->hook() is a > >>> NULL pointer but my patch shouldn't make any difference here... > >> No, its already in ipv4_confirm, so its most likely helper->help() > >> thats NULL, which is contained in an extension. > >> > >> The reason why I think its this patch is (quoting from an old > >> email that I never got a response to): > > > > Oh, I'm really sorry about that. > > No problem :) > > >> --- > >> Your patch introduced a use-after-free and double-free. > >> krealloc() frees the old pointer, but it is still used > >> for the ->move operations, then freed again. > >> > >> To fix this I think we need a __krealloc() that doesn't > >> free the old memory, especially since it must not be > >> freed immediately because it may still be used in a RCU > >> read side (see the last part in the patch attached to > >> this mail (based on a kernel without your patch)). > > > > Agreed. Something like this, perhaps? > > > > [PATCH] netfilter: fix double-free and use-after free > > > > As suggested by Patrick McHardy, introduce a __krealloc() that doesn't > > free the original buffer to fix a double-free and use-after-free bug > > introduced by me in netfilter that uses RCU. > > > > Reported-by: Patrick McHardy > > Signed-off-by: Pekka Enberg > > Looks good to me, thanks. Ingo, can you please test this? Andrew, I'm at OLS so can you pick up the patch in your tree? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/