* [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault
@ 2016-02-27 22:11 Oleg Nesterov
2016-02-29 11:02 ` [tip:x86/asm] " tip-bot for Oleg Nesterov
2016-02-29 11:42 ` [PATCH tip/x86/asm] " Peter Zijlstra
0 siblings, 2 replies; 5+ messages in thread
From: Oleg Nesterov @ 2016-02-27 22:11 UTC (permalink / raw)
To: Andy Lutomirski, Ingo Molnar
Cc: Jiri Olsa, Peter Zijlstra, Pratyush Anand, linux-kernel
As Jiri pointed out, the recent commit f872f5400cc0 "mm: Add a
vm_special_mapping.fault() method" breaks uprobes. __create_xol_area()
doesn't initialize the new ->fault() method and this obviously leads to
kernel crash when the application tries to execute the probed insn after
bp hit.
We probably want to add uprobes_special_mapping_fault(), this allows to
turn xol_area->xol_mapping into a single instance of vm_special_mapping.
But we need a simple fix, so lets change __create_xol() to nullify the
new member as Jiri suggests.
Reported-by: Jiri Olsa <jolsa@redhat.com>
Suggested-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/events/uprobes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 0167679..5f6ce93 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1178,6 +1178,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
goto free_area;
area->xol_mapping.name = "[uprobes]";
+ area->xol_mapping.fault = NULL;
area->xol_mapping.pages = area->pages;
area->pages[0] = alloc_page(GFP_HIGHUSER);
if (!area->pages[0])
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [tip:x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault
2016-02-27 22:11 [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault Oleg Nesterov
@ 2016-02-29 11:02 ` tip-bot for Oleg Nesterov
2016-02-29 11:42 ` [PATCH tip/x86/asm] " Peter Zijlstra
1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Oleg Nesterov @ 2016-02-29 11:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, tglx, panand, peterz, oleg, linux-kernel, hpa, tipbot,
jolsa, torvalds
Commit-ID: 869ae76147ffdf21ad24f0e599303cd58a2bb39f
Gitweb: http://git.kernel.org/tip/869ae76147ffdf21ad24f0e599303cd58a2bb39f
Author: Oleg Nesterov <oleg@redhat.com>
AuthorDate: Sat, 27 Feb 2016 23:11:28 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 29 Feb 2016 08:47:51 +0100
uprobes: __create_xol_area() must nullify xol_mapping.fault
As Jiri pointed out, this recent commit:
f872f5400cc0 ("mm: Add a vm_special_mapping.fault() method")
breaks uprobes: __create_xol_area() doesn't initialize the new ->fault()
method and this obviously leads to kernel crash when the application
tries to execute the probed insn after bp hit.
We probably want to add uprobes_special_mapping_fault(), this allows to
turn xol_area->xol_mapping into a single instance of vm_special_mapping.
But we need a simple fix, so lets change __create_xol() to nullify the
new member as Jiri suggests.
Suggested-by: Jiri Olsa <jolsa@redhat.com>
Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Andy Lutomirski <tipbot@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Pratyush Anand <panand@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160227221128.GA29565@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/events/uprobes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 0167679..5f6ce93 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1178,6 +1178,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
goto free_area;
area->xol_mapping.name = "[uprobes]";
+ area->xol_mapping.fault = NULL;
area->xol_mapping.pages = area->pages;
area->pages[0] = alloc_page(GFP_HIGHUSER);
if (!area->pages[0])
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault
2016-02-27 22:11 [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault Oleg Nesterov
2016-02-29 11:02 ` [tip:x86/asm] " tip-bot for Oleg Nesterov
@ 2016-02-29 11:42 ` Peter Zijlstra
2016-02-29 15:51 ` Oleg Nesterov
1 sibling, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2016-02-29 11:42 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Andy Lutomirski, Ingo Molnar, Jiri Olsa, Pratyush Anand,
linux-kernel
On Sat, Feb 27, 2016 at 11:11:28PM +0100, Oleg Nesterov wrote:
> As Jiri pointed out, the recent commit f872f5400cc0 "mm: Add a
> vm_special_mapping.fault() method" breaks uprobes. __create_xol_area()
> doesn't initialize the new ->fault() method and this obviously leads to
> kernel crash when the application tries to execute the probed insn after
> bp hit.
>
> We probably want to add uprobes_special_mapping_fault(), this allows to
> turn xol_area->xol_mapping into a single instance of vm_special_mapping.
> But we need a simple fix, so lets change __create_xol() to nullify the
> new member as Jiri suggests.
>
> Reported-by: Jiri Olsa <jolsa@redhat.com>
> Suggested-by: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> kernel/events/uprobes.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 0167679..5f6ce93 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1178,6 +1178,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
> goto free_area;
>
> area->xol_mapping.name = "[uprobes]";
> + area->xol_mapping.fault = NULL;
> area->xol_mapping.pages = area->pages;
Would not something like:
area->xol_mapping = (struct vm_special_mapping){
.name = "[uprobes]",
.pages = area->pages,
};
Be a more robust approach? That way, if someone adds more fields, they
at least get initialized (to 0).
> area->pages[0] = alloc_page(GFP_HIGHUSER);
> if (!area->pages[0])
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault
2016-02-29 11:42 ` [PATCH tip/x86/asm] " Peter Zijlstra
@ 2016-02-29 15:51 ` Oleg Nesterov
2016-02-29 16:14 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2016-02-29 15:51 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Andy Lutomirski, Ingo Molnar, Jiri Olsa, Pratyush Anand,
linux-kernel
On 02/29, Peter Zijlstra wrote:
>
> On Sat, Feb 27, 2016 at 11:11:28PM +0100, Oleg Nesterov wrote:
> > --- a/kernel/events/uprobes.c
> > +++ b/kernel/events/uprobes.c
> > @@ -1178,6 +1178,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
> > goto free_area;
> >
> > area->xol_mapping.name = "[uprobes]";
> > + area->xol_mapping.fault = NULL;
> > area->xol_mapping.pages = area->pages;
>
> Would not something like:
>
> area->xol_mapping = (struct vm_special_mapping){
> .name = "[uprobes]",
> .pages = area->pages,
> };
>
> Be a more robust approach? That way, if someone adds more fields, they
> at least get initialized (to 0).
OK, agreed...
Do you want me to send v2? Or incremental patch because this one is already in
-tip tree.
Or do nothing unless you feel strongly about it. area->xol_mapping should go away,
but we need a simple preparation in mm/mmap.c.
Oleg.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault
2016-02-29 15:51 ` Oleg Nesterov
@ 2016-02-29 16:14 ` Peter Zijlstra
0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2016-02-29 16:14 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Andy Lutomirski, Ingo Molnar, Jiri Olsa, Pratyush Anand,
linux-kernel
On Mon, Feb 29, 2016 at 04:51:14PM +0100, Oleg Nesterov wrote:
> On 02/29, Peter Zijlstra wrote:
> >
> > On Sat, Feb 27, 2016 at 11:11:28PM +0100, Oleg Nesterov wrote:
> > > --- a/kernel/events/uprobes.c
> > > +++ b/kernel/events/uprobes.c
> > > @@ -1178,6 +1178,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
> > > goto free_area;
> > >
> > > area->xol_mapping.name = "[uprobes]";
> > > + area->xol_mapping.fault = NULL;
> > > area->xol_mapping.pages = area->pages;
> >
> > Would not something like:
> >
> > area->xol_mapping = (struct vm_special_mapping){
> > .name = "[uprobes]",
> > .pages = area->pages,
> > };
> >
> > Be a more robust approach? That way, if someone adds more fields, they
> > at least get initialized (to 0).
>
> OK, agreed...
>
> Do you want me to send v2? Or incremental patch because this one is already in
> -tip tree.
>
> Or do nothing unless you feel strongly about it. area->xol_mapping should go away,
> but we need a simple preparation in mm/mmap.c.
Yeah, no real strong feelings. Esp. if you're working on getting it
killed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-02-29 16:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-27 22:11 [PATCH tip/x86/asm] uprobes: __create_xol_area() must nullify xol_mapping.fault Oleg Nesterov
2016-02-29 11:02 ` [tip:x86/asm] " tip-bot for Oleg Nesterov
2016-02-29 11:42 ` [PATCH tip/x86/asm] " Peter Zijlstra
2016-02-29 15:51 ` Oleg Nesterov
2016-02-29 16:14 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox