From: Petr Mladek <pmladek@suse.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>,
Jessica Yu <jeyu@redhat.com>, Jiri Kosina <jikos@kernel.org>,
Miroslav Benes <mbenes@suse.cz>
Cc: Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
live-patching@vger.kernel.org, linux-kernel@vger.kernel.org,
Petr Mladek <pmladek@suse.com>
Subject: [PATCH 1/3] livepatch/rcu: Guarantee consistency when patching idle kthreads
Date: Thu, 4 May 2017 12:55:14 +0200 [thread overview]
Message-ID: <1493895316-19165-2-git-send-email-pmladek@suse.com> (raw)
In-Reply-To: <1493895316-19165-1-git-send-email-pmladek@suse.com>
RCU is not watching idle threads because they are not scheduled
on busy CPUs and might block finishing grace periods. As a result,
the livepatch ftrace handler might see ops->func_stack and other
flags in a wrong state. Then a livepatch might make the system
unstable.
Note that there might be serious consequences only when the livepatch
modifies semantic of functions used by idle kthreads. We are safe when
none of the patched functions is used by the idle kthreads. Also
everything is good when the functions might be changed one by one
(using the immediate flag). See Documentation/livepatch/livepatch.txt
for more details about the consistency model.
This patch makes sure that even the idle threads see the critical
section by calling rcu_irq_enter_irqson(). The same fix was used
also for the stack tracer, see the commit a2d7629048322ae62b
("tracing: Have stack tracer force RCU to be watching").
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
kernel/livepatch/patch.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/livepatch/patch.c b/kernel/livepatch/patch.c
index f8269036bf0b..4c4fbe409008 100644
--- a/kernel/livepatch/patch.c
+++ b/kernel/livepatch/patch.c
@@ -59,6 +59,9 @@ static void notrace klp_ftrace_handler(unsigned long ip,
ops = container_of(fops, struct klp_ops, fops);
+ /* RCU may not be watching, make it see us. */
+ rcu_irq_enter_irqson();
+
rcu_read_lock();
func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
@@ -116,6 +119,7 @@ static void notrace klp_ftrace_handler(unsigned long ip,
klp_arch_set_pc(regs, (unsigned long)func->new_func);
unlock:
rcu_read_unlock();
+ rcu_irq_exit_irqson();
}
/*
--
1.8.5.6
next prev parent reply other threads:[~2017-05-04 10:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 10:55 [PATCH 0/3] livepatch/rcu: Handle some subtle issues between livepatching and RCU Petr Mladek
2017-05-04 10:55 ` Petr Mladek [this message]
2017-05-04 10:55 ` [PATCH 2/3] livepatch/rcu: Warn when system consistency is broken in RCU code Petr Mladek
2017-05-08 16:51 ` Josh Poimboeuf
2017-05-08 19:13 ` Steven Rostedt
2017-05-08 19:47 ` Josh Poimboeuf
2017-05-08 20:15 ` Paul E. McKenney
2017-05-08 20:43 ` Josh Poimboeuf
2017-05-08 20:51 ` Josh Poimboeuf
2017-05-08 21:08 ` Paul E. McKenney
2017-05-08 21:07 ` Paul E. McKenney
2017-05-08 21:18 ` Steven Rostedt
2017-05-08 21:30 ` Paul E. McKenney
2017-05-08 22:16 ` Josh Poimboeuf
2017-05-08 22:36 ` Paul E. McKenney
2017-05-09 16:18 ` Josh Poimboeuf
2017-05-09 16:36 ` Paul E. McKenney
2017-05-10 16:04 ` Petr Mladek
2017-05-10 16:45 ` Paul E. McKenney
2017-05-10 17:58 ` Josh Poimboeuf
2017-05-11 12:40 ` Miroslav Benes
2017-05-11 15:03 ` Josh Poimboeuf
2017-05-08 21:16 ` Steven Rostedt
2017-05-08 20:18 ` Steven Rostedt
2017-05-11 12:50 ` Miroslav Benes
2017-05-11 13:52 ` Petr Mladek
2017-05-11 14:50 ` Paul E. McKenney
2017-05-11 15:27 ` Josh Poimboeuf
2017-05-11 12:44 ` Petr Mladek
2017-05-04 10:55 ` [PATCH 3/3] livepatch/rcu: Disable livepatch removal when safety is not guaranteed Petr Mladek
2017-05-04 16:55 ` [PATCH 0/3] livepatch/rcu: Handle some subtle issues between livepatching and RCU Paul E. McKenney
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=1493895316-19165-2-git-send-email-pmladek@suse.com \
--to=pmladek@suse.com \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
/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
Powered by JetHome