public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Petr Mladek <pmladek@suse.cz>,
	sjenning@redhat.com, vojtech@suse.cz,
	masami.hiramatsu.pt@hitachi.com, mbenes@suse.cz,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] livepatch: RCU protect struct klp_func all the time when used in klp_ftrace_handler()
Date: Fri, 20 Feb 2015 21:52:50 -0600	[thread overview]
Message-ID: <20150221035250.GA15563@treble.redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1502210028160.19198@pobox.suse.cz>

On Sat, Feb 21, 2015 at 12:29:30AM +0100, Jiri Kosina wrote:
> On Wed, 18 Feb 2015, Petr Mladek wrote:
> 
> > func->new_func has been accessed after rcu_read_unlock() in klp_ftrace_handler()
> > and therefore the access was not protected.
> > 
> > Signed-off-by: Petr Mladek <pmladek@suse.cz>
> > ---
> >  kernel/livepatch/core.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> > index ff7f47d026ac..cde66192e20e 100644
> > --- a/kernel/livepatch/core.c
> > +++ b/kernel/livepatch/core.c
> > @@ -314,12 +314,12 @@ static void notrace klp_ftrace_handler(unsigned long ip,
> >  	rcu_read_lock();
> >  	func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
> >  				      stack_node);
> > -	rcu_read_unlock();
> > -
> >  	if (WARN_ON_ONCE(!func))
> > -		return;
> > +		goto unlock;
> >  
> >  	klp_arch_set_pc(regs, (unsigned long)func->new_func);
> > +unlock:
> > +	rcu_read_unlock();
> 
> This can't hurt, even though the only scenario where this could in theory 
> trigger as a bug (module removal) is non-issue now.
> 
> But I'd like to take it nevertheless ... Seth, Josh?

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>

-- 
Josh

  reply	other threads:[~2015-02-21  3:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 17:02 [PATCH] livepatch: RCU protect struct klp_func all the time when used in klp_ftrace_handler() Petr Mladek
2015-02-20 23:29 ` Jiri Kosina
2015-02-21  3:52   ` Josh Poimboeuf [this message]
2015-02-22 22:03 ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150221035250.GA15563@treble.redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.cz \
    --cc=sjenning@redhat.com \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox