[PATCH -next v1 3/3] kernel/events/uprobes: uprobe_write_opcode() rewrite
David Hildenbrand
david at redhat.com
Tue Mar 11 13:02:49 PDT 2025
On 11.03.25 13:32, Oleg Nesterov wrote:
> On 03/11, David Hildenbrand wrote:
>>
>> 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.
>
>>> 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
More information about the linux-arm-kernel
mailing list