Commit 75ed82ea53bd0d2d8083261123576250f7ba851e

Authored by Oleg Nesterov
1 parent db023ea595

uprobes: Change write_opcode() to use FOLL_FORCE

write_opcode()->get_user_pages() needs FOLL_FORCE to ensure we can
read the page even if the probed task did mprotect(PROT_NONE) after
uprobe_register(). Without FOLL_WRITE, FOLL_FORCE doesn't have any
side effect but allows to read the !VM_READ memory.

Otherwiese the subsequent uprobe_unregister()->set_orig_insn() fails
and we leak "int3". If that task does mprotect(PROT_READ | EXEC) and
execute the probed insn later it will be killed.

Note: in fact this is also needed for _register, see the next patch.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

kernel/events/uprobes.c
... ... @@ -221,7 +221,7 @@
221 221  
222 222 retry:
223 223 /* Read the page with vaddr into memory */
224   - ret = get_user_pages(NULL, mm, vaddr, 1, 0, 0, &old_page, &vma);
  224 + ret = get_user_pages(NULL, mm, vaddr, 1, 0, 1, &old_page, &vma);
225 225 if (ret <= 0)
226 226 return ret;
227 227