From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754808Ab2AIIUB (ORCPT ); Mon, 9 Jan 2012 03:20:01 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:45178 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754536Ab2AIIT7 (ORCPT ); Mon, 9 Jan 2012 03:19:59 -0500 Date: Mon, 9 Jan 2012 13:50:02 +0530 From: Ananth N Mavinakayanahalli To: lkml Cc: Jim Keniston , Masami Hiramatsu , stable@vger.kernel.org Subject: [PATCH][RESEND] kprobes: initialize before using a hlist Message-ID: <20120109082001.GE20666@in.ibm.com> Reply-To: ananth@in.ibm.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) x-cbid: 12010908-5806-0000-0000-00001132DB8C Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ananth N Mavinakayanahalli Commit ef53d9c5e introduced a bug where we can potentially leak kretprobe_instances since we initialize a hlist head after having used it. Initialize the hlist head before using it. (Resent with correct email ID for -stable) Reported by: Jim Keniston Signed-off-by: Ananth N Mavinakayanahalli Cc: Masami Hiramatsu Cc: --- kernel/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-3.2/kernel/kprobes.c =================================================================== --- linux-3.2.orig/kernel/kprobes.c +++ linux-3.2/kernel/kprobes.c @@ -1077,6 +1077,7 @@ void __kprobes kprobe_flush_task(struct /* Early boot. kretprobe_table_locks not yet initialized. */ return; + INIT_HLIST_HEAD(&empty_rp); hash = hash_ptr(tk, KPROBE_HASH_BITS); head = &kretprobe_inst_table[hash]; kretprobe_table_lock(hash, &flags); @@ -1085,7 +1086,6 @@ void __kprobes kprobe_flush_task(struct recycle_rp_inst(ri, &empty_rp); } kretprobe_table_unlock(hash, &flags); - INIT_HLIST_HEAD(&empty_rp); hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) { hlist_del(&ri->hlist); kfree(ri);