Re: Oops caused by race between livepatch and ftrace

2019-05-29 Thread Jessica Yu
+++ Josh Poimboeuf [29/05/19 12:39 -0500]: On Wed, May 29, 2019 at 07:29:04PM +0200, Jessica Yu wrote: +++ Josh Poimboeuf [21/05/19 11:42 -0500]: > On Tue, May 21, 2019 at 10:42:04AM -0400, Steven Rostedt wrote: > > On Tue, 21 May 2019 09:16:29 -0500 > > Josh Poimboeuf wrote: > > > > > > Hmm, t

Re: Oops caused by race between livepatch and ftrace

2019-05-29 Thread Josh Poimboeuf
On Wed, May 29, 2019 at 07:29:04PM +0200, Jessica Yu wrote: > +++ Josh Poimboeuf [21/05/19 11:42 -0500]: > > On Tue, May 21, 2019 at 10:42:04AM -0400, Steven Rostedt wrote: > > > On Tue, 21 May 2019 09:16:29 -0500 > > > Josh Poimboeuf wrote: > > > > > > > > Hmm, this may blow up with lockdep, as

Re: Oops caused by race between livepatch and ftrace

2019-05-29 Thread Jessica Yu
+++ Josh Poimboeuf [21/05/19 11:42 -0500]: On Tue, May 21, 2019 at 10:42:04AM -0400, Steven Rostedt wrote: On Tue, 21 May 2019 09:16:29 -0500 Josh Poimboeuf wrote: > > Hmm, this may blow up with lockdep, as I believe we already have a > > locking dependency of: > > > > text_mutex -> ftrace_lo

Re: Oops caused by race between livepatch and ftrace

2019-05-29 Thread Josh Poimboeuf
On Wed, May 29, 2019 at 08:06:48AM -0400, Steven Rostedt wrote: > On Wed, 29 May 2019 13:17:21 +0200 (CEST) > Jiri Kosina wrote: > > > > > From: Josh Poimboeuf > > > > Subject: [PATCH] livepatch: Fix ftrace module text permissions race > > > > > > Thanks, > > > > > > I'll try to find some ti

Re: Oops caused by race between livepatch and ftrace

2019-05-29 Thread Steven Rostedt
On Wed, 29 May 2019 13:17:21 +0200 (CEST) Jiri Kosina wrote: > > > From: Josh Poimboeuf > > > Subject: [PATCH] livepatch: Fix ftrace module text permissions race > > > > Thanks, > > > > I'll try to find some time to test this as well. > > Steve, Jessica, any final word on this? I was und

Re: Oops caused by race between livepatch and ftrace

2019-05-29 Thread Jiri Kosina
On Tue, 21 May 2019, Steven Rostedt wrote: > > Hm. I suppose using ftrace_lock might be less risky since that lock > > is only used internally by ftrace (up until now). But I think it > > would also make less sense because the text_mutex is supposed to > > protect code patching. And presumab

Re: Oops caused by race between livepatch and ftrace

2019-05-22 Thread Josh Poimboeuf
On Tue, May 21, 2019 at 11:42:27AM -0500, Josh Poimboeuf wrote: > void module_enable_ro(const struct module *mod, bool after_init) > { > + lockdep_assert_held(&text_mutex); > + This assertion fails, it turns out the module code also calls this function (oops). I may move the meat of this fu

Re: Oops caused by race between livepatch and ftrace

2019-05-21 Thread Josh Poimboeuf
On Tue, May 21, 2019 at 03:27:47PM -0400, Joe Lawrence wrote: > BTW, livepatching folks -- speaking of this window, does it make sense for > klp_init_object_loaded() to unconditionally frob the module section > permissions? Should it only bother iff it's going to apply > relocations/alternatives/p

Re: Oops caused by race between livepatch and ftrace

2019-05-21 Thread Joe Lawrence
On 5/20/19 5:19 PM, Joe Lawrence wrote: On 5/20/19 5:09 PM, Johannes Erdfelt wrote: On Mon, May 20, 2019, Joe Lawrence wrote: These two testing scenarios might be interesting to add to our selftests suite. Can you post or add the source(s) to livepatch-test.ko to the tarball? I made the liv

Re: Oops caused by race between livepatch and ftrace

2019-05-21 Thread Steven Rostedt
On Tue, 21 May 2019 11:42:27 -0500 Josh Poimboeuf wrote: > Hm. I suppose using ftrace_lock might be less risky since that lock is > only used internally by ftrace (up until now). But I think it would > also make less sense because the text_mutex is supposed to protect code > patching. And pres

Re: Oops caused by race between livepatch and ftrace

2019-05-21 Thread Josh Poimboeuf
On Tue, May 21, 2019 at 10:42:04AM -0400, Steven Rostedt wrote: > On Tue, 21 May 2019 09:16:29 -0500 > Josh Poimboeuf wrote: > > > > Hmm, this may blow up with lockdep, as I believe we already have a > > > locking dependency of: > > > > > > text_mutex -> ftrace_lock > > > > > > And this will r

Re: Oops caused by race between livepatch and ftrace

2019-05-21 Thread Steven Rostedt
On Tue, 21 May 2019 09:16:29 -0500 Josh Poimboeuf wrote: > > Hmm, this may blow up with lockdep, as I believe we already have a > > locking dependency of: > > > > text_mutex -> ftrace_lock > > > > And this will reverses it. (kprobes appears to take the locks in this > > order). > > > > Perhap

Re: Oops caused by race between livepatch and ftrace

2019-05-21 Thread Josh Poimboeuf
On Mon, May 20, 2019 at 05:39:10PM -0400, Steven Rostedt wrote: > On Mon, 20 May 2019 16:19:31 -0500 > Josh Poimboeuf wrote: > > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > > index a12aff849c04..8259d4ba8b00 100644 > > --- a/kernel/trace/ftrace.c > > +++ b/kernel/trace/ftrace.c

Re: Oops caused by race between livepatch and ftrace

2019-05-20 Thread Johannes Erdfelt
On Mon, May 20, 2019, Josh Poimboeuf wrote: > I think you must have been looking at an old version. > > [(v5.2-rc1)] ~/git/linux $ grep jeyu MAINTAINERS > M:Jessica Yu Operator error on my part. I was looking at a different directory with an old branch checked out. Sorry! > Can you try thi

Re: Oops caused by race between livepatch and ftrace

2019-05-20 Thread Steven Rostedt
On Mon, 20 May 2019 16:19:31 -0500 Josh Poimboeuf wrote: > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index a12aff849c04..8259d4ba8b00 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > >

Re: Oops caused by race between livepatch and ftrace

2019-05-20 Thread Josh Poimboeuf
On Mon, May 20, 2019 at 02:09:05PM -0700, Johannes Erdfelt wrote: > On Mon, May 20, 2019, Joe Lawrence wrote: > > [ fixed jeyu's email address ] > > Thank you, the bounce message made it seem like my mail server was > blocked and not that the address didn't exist. > > I think MAINTAINERS needs a

Re: Oops caused by race between livepatch and ftrace

2019-05-20 Thread Joe Lawrence
On 5/20/19 5:09 PM, Johannes Erdfelt wrote: On Mon, May 20, 2019, Joe Lawrence wrote: [ fixed jeyu's email address ] Thank you, the bounce message made it seem like my mail server was blocked and not that the address didn't exist. I think MAINTAINERS needs an update since it still has the @r

Re: Oops caused by race between livepatch and ftrace

2019-05-20 Thread Johannes Erdfelt
On Mon, May 20, 2019, Joe Lawrence wrote: > [ fixed jeyu's email address ] Thank you, the bounce message made it seem like my mail server was blocked and not that the address didn't exist. I think MAINTAINERS needs an update since it still has the @redhat.com address. > On 5/20/19 3:49 PM, Joha

Re: Oops caused by race between livepatch and ftrace

2019-05-20 Thread Joe Lawrence
[ fixed jeyu's email address ] On 5/20/19 3:49 PM, Johannes Erdfelt wrote: [ ... snip ... ] I have put together a test case that can reproduce the crash using KVM. The tarball includes a minimal kernel and initramfs, along with a script to run qemu and the .config used to build the kernel. By d