From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936166AbXGTBbU (ORCPT ); Thu, 19 Jul 2007 21:31:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761107AbXGTBbM (ORCPT ); Thu, 19 Jul 2007 21:31:12 -0400 Received: from smtp2.linux-foundation.org ([207.189.120.14]:52176 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759851AbXGTBbK (ORCPT ); Thu, 19 Jul 2007 21:31:10 -0400 Date: Thu, 19 Jul 2007 18:29:52 -0700 From: Andrew Morton To: Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, Paul Mundt , Tom Zanussi , Karim Yaghmour , Jesper Juhl , "David J. Wilder" Subject: Re: [PATCH] Fix a use after free bug in kernel->userspace relay file support Message-Id: <20070719182952.5f437e64.akpm@linux-foundation.org> In-Reply-To: <20070720010909.GA4298@Krystal> References: <20070720010909.GA4298@Krystal> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.6; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Jul 2007 21:09:09 -0400 Mathieu Desnoyers wrote: > Coverity spotted what looks like a real possible case of using a > variable after it has been freed. > The problem is in kernel/relay.c::relay_open_buf() > > If the code hits "goto free_buf;" it ends up in this code : > > free_buf: > relay_destroy_buf(buf); <--- calls kfree() on 'buf'. > free_name: > kfree(tmpname); > end: > return buf; <-- use after free of 'buf'. > > I read through the callers and they all handle a NULL return > from this function as an error (and hitting the 'free_buf' label > only happens on failure to chan->cb->create_buf_file(), so that > looks like a clear error to me). > > The patch simply sets 'buf' to NULL after the call to > relay_destroy_buf(buf); - as far as I can see that should take > care of the problem. > > The patch also corrects a reference to a documentation file while > I was at it. > > Note from Mathieu: the documentation reference change should have been > done in a separate patch, but I guess no one will really care. > > Signed-off-by: Jesper Juhl > Acked-by: "David J. Wilder" > Tested-by: "David J. Wilder" > Signed-off-by: Mathieu Desnoyers I'm going to infer from all this that the patch was actually written by Jesper. Correct? If so, it shuld have had From: Jesper Juhl right at the start of the changelog.