diff options
author | Roland McGrath <roland@redhat.com> | 2008-07-25 22:45:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-26 15:00:09 -0400 |
commit | fa8e26ccd485216fc45c8c2dd1ec3b7ef1a0a2f8 (patch) | |
tree | b6c3059593d7d185aaf7f5b69c363a48b18c5bb1 | |
parent | 0d094efeb1e98010c6b99923f1eb7e17bf1e3a74 (diff) |
tracehook: tracehook_expect_breakpoints
This adds tracehook_expect_breakpoints() as a formal hook for the nommu
code to use for its, "Is text-poking likely?" check at mmap time. This
names the actual semantics the code means to test, and documents it.
Signed-off-by: Roland McGrath <roland@redhat.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Reviewed-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/tracehook.h | 15 | ||||
-rw-r--r-- | mm/nommu.c | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 6468ca0fe69b..e113e09b0341 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h | |||
@@ -52,6 +52,21 @@ | |||
52 | struct linux_binprm; | 52 | struct linux_binprm; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * tracehook_expect_breakpoints - guess if task memory might be touched | ||
56 | * @task: current task, making a new mapping | ||
57 | * | ||
58 | * Return nonzero if @task is expected to want breakpoint insertion in | ||
59 | * its memory at some point. A zero return is no guarantee it won't | ||
60 | * be done, but this is a hint that it's known to be likely. | ||
61 | * | ||
62 | * May be called with @task->mm->mmap_sem held for writing. | ||
63 | */ | ||
64 | static inline int tracehook_expect_breakpoints(struct task_struct *task) | ||
65 | { | ||
66 | return (task_ptrace(task) & PT_PTRACED) != 0; | ||
67 | } | ||
68 | |||
69 | /** | ||
55 | * tracehook_unsafe_exec - check for exec declared unsafe due to tracing | 70 | * tracehook_unsafe_exec - check for exec declared unsafe due to tracing |
56 | * @task: current task doing exec | 71 | * @task: current task doing exec |
57 | * | 72 | * |
diff --git a/mm/nommu.c b/mm/nommu.c index 4462b6a3fcb9..5edccd9c9218 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/pagemap.h> | 22 | #include <linux/pagemap.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/vmalloc.h> | 24 | #include <linux/vmalloc.h> |
25 | #include <linux/ptrace.h> | 25 | #include <linux/tracehook.h> |
26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
27 | #include <linux/backing-dev.h> | 27 | #include <linux/backing-dev.h> |
28 | #include <linux/mount.h> | 28 | #include <linux/mount.h> |
@@ -745,7 +745,7 @@ static unsigned long determine_vm_flags(struct file *file, | |||
745 | * it's being traced - otherwise breakpoints set in it may interfere | 745 | * it's being traced - otherwise breakpoints set in it may interfere |
746 | * with another untraced process | 746 | * with another untraced process |
747 | */ | 747 | */ |
748 | if ((flags & MAP_PRIVATE) && (current->ptrace & PT_PTRACED)) | 748 | if ((flags & MAP_PRIVATE) && tracehook_expect_breakpoints(current)) |
749 | vm_flags &= ~VM_MAYSHARE; | 749 | vm_flags &= ~VM_MAYSHARE; |
750 | 750 | ||
751 | return vm_flags; | 751 | return vm_flags; |