diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/perf_event.h> | 30 | #include <linux/perf_event.h> |
31 | #include <linux/audit.h> | 31 | #include <linux/audit.h> |
32 | #include <linux/khugepaged.h> | 32 | #include <linux/khugepaged.h> |
33 | #include <linux/uprobes.h> | ||
33 | 34 | ||
34 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
35 | #include <asm/cacheflush.h> | 36 | #include <asm/cacheflush.h> |
@@ -616,6 +617,13 @@ again: remove_next = 1 + (end > next->vm_end); | |||
616 | if (mapping) | 617 | if (mapping) |
617 | mutex_unlock(&mapping->i_mmap_mutex); | 618 | mutex_unlock(&mapping->i_mmap_mutex); |
618 | 619 | ||
620 | if (root) { | ||
621 | mmap_uprobe(vma); | ||
622 | |||
623 | if (adjust_next) | ||
624 | mmap_uprobe(next); | ||
625 | } | ||
626 | |||
619 | if (remove_next) { | 627 | if (remove_next) { |
620 | if (file) { | 628 | if (file) { |
621 | fput(file); | 629 | fput(file); |
@@ -637,6 +645,8 @@ again: remove_next = 1 + (end > next->vm_end); | |||
637 | goto again; | 645 | goto again; |
638 | } | 646 | } |
639 | } | 647 | } |
648 | if (insert && file) | ||
649 | mmap_uprobe(insert); | ||
640 | 650 | ||
641 | validate_mm(mm); | 651 | validate_mm(mm); |
642 | 652 | ||
@@ -1329,6 +1339,11 @@ out: | |||
1329 | mm->locked_vm += (len >> PAGE_SHIFT); | 1339 | mm->locked_vm += (len >> PAGE_SHIFT); |
1330 | } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK)) | 1340 | } else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK)) |
1331 | make_pages_present(addr, addr + len); | 1341 | make_pages_present(addr, addr + len); |
1342 | |||
1343 | if (file && mmap_uprobe(vma)) | ||
1344 | /* matching probes but cannot insert */ | ||
1345 | goto unmap_and_free_vma; | ||
1346 | |||
1332 | return addr; | 1347 | return addr; |
1333 | 1348 | ||
1334 | unmap_and_free_vma: | 1349 | unmap_and_free_vma: |
@@ -2285,6 +2300,10 @@ int insert_vm_struct(struct mm_struct * mm, struct vm_area_struct * vma) | |||
2285 | if ((vma->vm_flags & VM_ACCOUNT) && | 2300 | if ((vma->vm_flags & VM_ACCOUNT) && |
2286 | security_vm_enough_memory_mm(mm, vma_pages(vma))) | 2301 | security_vm_enough_memory_mm(mm, vma_pages(vma))) |
2287 | return -ENOMEM; | 2302 | return -ENOMEM; |
2303 | |||
2304 | if (vma->vm_file && mmap_uprobe(vma)) | ||
2305 | return -EINVAL; | ||
2306 | |||
2288 | vma_link(mm, vma, prev, rb_link, rb_parent); | 2307 | vma_link(mm, vma, prev, rb_link, rb_parent); |
2289 | return 0; | 2308 | return 0; |
2290 | } | 2309 | } |
@@ -2354,6 +2373,10 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, | |||
2354 | new_vma->vm_pgoff = pgoff; | 2373 | new_vma->vm_pgoff = pgoff; |
2355 | if (new_vma->vm_file) { | 2374 | if (new_vma->vm_file) { |
2356 | get_file(new_vma->vm_file); | 2375 | get_file(new_vma->vm_file); |
2376 | |||
2377 | if (mmap_uprobe(new_vma)) | ||
2378 | goto out_free_mempol; | ||
2379 | |||
2357 | if (vma->vm_flags & VM_EXECUTABLE) | 2380 | if (vma->vm_flags & VM_EXECUTABLE) |
2358 | added_exe_file_vma(mm); | 2381 | added_exe_file_vma(mm); |
2359 | } | 2382 | } |