From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, uclinux-dev@uclinux.org,
dhowells@redhat.com
Subject: [PATCH] NOMMU: Permit ptrace to ignore non-PROT_WRITE VMAs in NOMMU mode
Date: Thu, 31 Aug 2006 21:24:29 +0100 [thread overview]
Message-ID: <20060831202429.24083.96888.stgit@warthog.cambridge.redhat.com> (raw)
From: David Howells <dhowells@redhat.com>
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>
---
mm/nommu.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index 51e17b9..9d57c2a 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1234,9 +1234,9 @@ int access_process_vm(struct task_struct
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;
reply other threads:[~2006-08-31 20:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060831202429.24083.96888.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=uclinux-dev@uclinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®