Skip to content

Commit

Permalink
[PATCH] NOMMU: Permit ptrace to ignore non-PROT_WRITE VMAs in NOMMU mode
Browse files Browse the repository at this point in the history
Permit ptrace to modify a section that's non-shared but is marked
unwritable, such as is obtained by mapping the text segment of an ELF-FDPIC
executable binary with into a binary that's being ptraced[*].

[*] Under NOMMU conditions ptrace causes read-only MAP_PRIVATE mmaps to become
    totally private copies because if a private mapping was actually shared
    then the debugging setting breakpoints in it would potentially crash
    other processes.

This is done by using the VM_MAYWRITE flag rather than the VM_WRITE flag
when deciding whether to permit a write.

Without this patch a debugger can't set breakpoints in the mapped text
sections of executables that are mapped read-only private, even if the
mmap() syscall has taken a private copy because PT_PTRACED is set.

In addition, VM_MAYREAD is used instead of VM_READ for similar reasons.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
dhowells authored and Linus Torvalds committed Sep 27, 2006
1 parent 7b4d5b8 commit d00c7b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,9 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in
len = vma->vm_end - addr;

/* only read or write mappings where it is permitted */
if (write && vma->vm_flags & VM_WRITE)
if (write && vma->vm_flags & VM_MAYWRITE)
len -= copy_to_user((void *) addr, buf, len);
else if (!write && vma->vm_flags & VM_READ)
else if (!write && vma->vm_flags & VM_MAYREAD)
len -= copy_from_user(buf, (void *) addr, len);
else
len = 0;
Expand Down

0 comments on commit d00c7b9

Please sign in to comment.