Thread (15 messages) 15 messages, 4 authors, 2025-03-11

Re: [PATCH -next v1 3/3] kernel/events/uprobes: uprobe_write_opcode() rewrite

From: David Hildenbrand <hidden>
Date: 2025-03-11 20:02:55
Also in: linux-arm-kernel, linux-mm, linux-perf-users, lkml

On 11.03.25 13:32, Oleg Nesterov wrote:
On 03/11, David Hildenbrand wrote:
quoted
Regarding both questions, the code is fairly racy. Nothing would stop user
space from (a) modifying that memory
Yes, but we don't really care. uprobes.c assumes that user-space won't play
with the probed memory.
Right, I primarily care about that if user space would do it, that we 
don't trigger unintended behavior (e.g., overwriting pagecache pages 
etc, WARN etc).

Likely the re-validating the page content is indeed something we can drop.
Note that if is_register is false, then vma can be even writable. Hmm, why?
Perhaps valid_vma() should ignore is_register and nack VM_MAYWRITE ? But
this doesn't really matter, say, gdb can change this memory anyway. Again,
we don't really care.
quoted
quoted
do something like

	/* Walk the page tables again, to perform the actual update. */
	ret = -EAGAIN;
	folio = folio_walk_start(&fw, vma, vaddr, 0);
	if (folio) {
		if (fw.page == page) {
			WARN_ON(is_register && !folio_test_anon(folio));
Yes, that would work (we could leave the WARN_ON in __uprobe_write_opcode),
but I am not sure if the end result is better better. No strong opinion on
the details though.
Will, this way __uprobe_write_opcode() will look a little bit simpler...

But I won't insist, please do what you think is better.
I'll take another look at this series probably next week (I'm on PTO 
this week) to then resend once adjusted + retested.

Thanks!

-- 
Cheers,

David / dhildenb
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help