public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* uprobes misses breakpoint insertion into VM_WRITE mappings
@ 2018-03-15 20:48 Mathieu Desnoyers
  2018-03-16 16:52 ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Desnoyers @ 2018-03-15 20:48 UTC (permalink / raw)
  To: Oleg Nesterov, Erica Bugden
  Cc: Srikar Dronamraju, rostedt, Ingo Molnar, Peter Zijlstra,
	Thomas Gleixner, linux-kernel

Hi,

Erica has been working on extending test-cases for uprobes, and found
something unexpected:

Since commit e40cfce626a5 "uprobes: Restrict valid_vma(false) to skip VM_SHARED vmas"
uprobes does not insert breakpoints into mappings mprotect'd as writeable.

This issue can be reproduced by compiling a library without PIC (not using GOT),
and then concurrently:

A) Load the library (dynamic loader mprotect the code as writeable to do
   the relocations, and then mprotect as executable),

B) Enable a uprobe through perf.

(it is a race window between the two mprotect syscalls)

It appears that the following restriction in valid_vma() is responsible
for this behavior:

        if (is_register)
                flags |= VM_WRITE;

I don't figure a clear explanation for this flag based on the function
comment nor the commit changelog. Any idea on whether this is really
needed ?

Note that on uprobes unregister, it allows removing a breakpoint event
on a writeable mapping, so there is clearly a discrepancy between the
level of paranoia associated with registration and unregistration.

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-22 21:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-15 20:48 uprobes misses breakpoint insertion into VM_WRITE mappings Mathieu Desnoyers
2018-03-16 16:52 ` Oleg Nesterov
2018-03-22 21:48   ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox