Re: [PATCH] Add a text_poke syscall v2

Oleg Nesterov
2013-11-29T18:35:30Z

On 11/25, Andi Kleen wrote:
>
> + err = get_user_pages_fast((unsigned long)addr, npages, 1, pages);
> + if (err < 0)
> + return err;
> + if (err != npages) {
> + err = -EFAULT;
> + goto out;
> + }
> + err = 0;
> + mutex_lock(&text_mutex);
> + bp_target_mm = current->mm;
> + bp_int3_addr = (u8 *)addr + 1;
> + __text_poke_bp(pages,
> + (unsigned long)addr & ~PAGE_MASK,
> + insn, len, handler);

We are going to change this user page, it seems that we need
set_page_dirty() ?

Andi, et al. I am going to discuss the things I do not really
understand, probably this can't make any sense, but...

I am wondering if sys_text_poke() can do something like

down_write(mmap_sem);

get_user_pages(write, page, vma);

ptep = page_check_address(...);

pte = ptep_clear_flush(ptep);

copy-opcode-to-page;

pte = pte_mkdirty(pte);
set_pte_at(ptep, pte);

pte_unmap_unlock(...);
up_write(mmap_sem);

?

Oleg.