From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755101AbbCBTWE (ORCPT ); Mon, 2 Mar 2015 14:22:04 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:51224 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754254AbbCBTWB (ORCPT ); Mon, 2 Mar 2015 14:22:01 -0500 Date: Mon, 2 Mar 2015 11:21:54 -0800 From: "Paul E. McKenney" To: Peter Zijlstra Cc: mingo@kernel.org, rusty@rustcorp.com.au, mathieu.desnoyers@efficios.com, oleg@redhat.com, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, Seth Jennings , Josh Poimboeuf , Masami Hiramatsu , Miroslav Benes , Petr Mladek , Jiri Kosina Subject: Re: [RFC][PATCH 1/9] klp: Fix obvious RCU fail Message-ID: <20150302192154.GQ15405@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20150228212447.381543289@infradead.org> <20150228213109.893891745@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150228213109.893891745@infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15030219-0013-0000-0000-000009266759 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: Paul E. McKenney > --- > 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); > >