From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932127AbbCBVIN (ORCPT ); Mon, 2 Mar 2015 16:08:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59657 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932105AbbCBVIL (ORCPT ); Mon, 2 Mar 2015 16:08:11 -0500 Date: Mon, 2 Mar 2015 15:07:08 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: mingo@kernel.org, rusty@rustcorp.com.au, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, Seth Jennings , Masami Hiramatsu , Miroslav Benes , Petr Mladek , Jiri Kosina Subject: Re: [RFC][PATCH 1/9] klp: Fix obvious RCU fail Message-ID: <20150302210708.GA26554@treble.redhat.com> References: <20150228212447.381543289@infradead.org> <20150228213109.893891745@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150228213109.893891745@infradead.org> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 28, 2015 at 10:24:48PM +0100, Peter Zijlstra wrote: > While one must hold RCU-sched (aka. preempt_disable) for find_symbol() > one must equally hold it over the use of the object returned. > > The moment you release the RCU-sched read lock, the object can be dead > and gone. > > Cc: Seth Jennings > Cc: Josh Poimboeuf > Cc: Masami Hiramatsu > Cc: Miroslav Benes > Cc: Petr Mladek > Cc: Jiri Kosina > Cc: "Paul E. McKenney" > Cc: Rusty Russell > Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf > --- > kernel/livepatch/core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -248,11 +248,12 @@ static int klp_find_external_symbol(stru > /* first, check if it's an exported symbol */ > preempt_disable(); > sym = find_symbol(name, NULL, NULL, true, true); > - preempt_enable(); > if (sym) { > *addr = sym->value; > + preempt_enable(); > return 0; > } > + preempt_enable(); > > /* otherwise check if it's in another .o within the patch module */ > return klp_find_object_symbol(pmod->name, name, addr); > > -- Josh