lkml.org 
[lkml]   [2009]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [BUGFIX][PATCH -rc/-mm] prevent kprobes from catching spurious page faults
Mathieu Desnoyers wrote:
> * Ingo Molnar (mingo@elte.hu) wrote:
>> * Masami Hiramatsu <mhiramat@redhat.com> wrote:
>>
>>> - if (notify_page_fault(regs))
>>> - return;
>>> if (unlikely(kmmio_fault(regs, address)))
>>> return;
>>>
>>> @@ -634,6 +632,9 @@ void __kprobes do_page_fault(struct pt_r
>>> if (spurious_fault(address, error_code))
>>> return;
>>>
>>> + /* kprobes don't want to hook the spurious faults. */
>>> + if (notify_page_fault(regs))
>>> + return;
>>> /*
>>> * Don't take the mm semaphore here. If we fixup a prefetch
>>> * fault we could otherwise deadlock.
>>> @@ -641,6 +642,9 @@ void __kprobes do_page_fault(struct pt_r
>>> goto bad_area_nosemaphore;
>>> }
>>>
>>> + /* kprobes don't want to hook the spurious faults. */
>>> + if (notify_page_fault(regs))
>>> + return;
>> I dont know - this spreads that callback to two places now. Any
>> reason why kprobes cannot call spurious_fault(), if there's a
>> probe active?
>>
>> Also, moving that would remove the planned cleanup of merging these
>> two into one call:
>>
>> if (notify_page_fault(regs))
>> return;
>> if (unlikely(kmmio_fault(regs, address)))
>> return;
>>
>> We should reduce the probing cross section, not increase it,
>> especially in such a critical codepath as the pagefault handler.
>>
>> Btw., why cannot kprobes install a dynamic probe to the fault
>> handler itself? That way the default path would have no such
>> callbacks and checks at all.
>>
>
> Or we could simply merge my 2 LTTng page fault handler tracepoints per
> architecture and be done with it ?

As you can see, these functions are a kind of fixup code.
If it succeed fixup a fault, do_page_fault() has to return because
the fault is fixed.

Since tracepoint itself is just a watchpoint, it should not
change code path. So, I think just moving kmmio_fault() to
notify_page_fault() is enough.

> I'd need to clean up the patchset a little bit to fold a few patches,
> but that would be straightforward enough.

Anyway, I agree with the idea to push tracepoint in the pagefault.
It is very useful for watching system behavior.

Thanks!


>
> Mathieu
>

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com



\
 
 \ /
  Last update: 2009-02-06 17:33    [W:0.089 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site