diff options
-rw-r--r-- | kernel/module.c | 5 | ||||
-rw-r--r-- | mm/nommu.c | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c index b6ee424245dd..e6bc4b28aa62 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/rculist.h> | 47 | #include <linux/rculist.h> |
48 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
49 | #include <asm/cacheflush.h> | 49 | #include <asm/cacheflush.h> |
50 | #include <asm/mmu_context.h> | ||
50 | #include <linux/license.h> | 51 | #include <linux/license.h> |
51 | #include <asm/sections.h> | 52 | #include <asm/sections.h> |
52 | #include <linux/tracepoint.h> | 53 | #include <linux/tracepoint.h> |
@@ -1535,6 +1536,10 @@ static void free_module(struct module *mod) | |||
1535 | 1536 | ||
1536 | /* Finally, free the core (containing the module structure) */ | 1537 | /* Finally, free the core (containing the module structure) */ |
1537 | module_free(mod, mod->module_core); | 1538 | module_free(mod, mod->module_core); |
1539 | |||
1540 | #ifdef CONFIG_MPU | ||
1541 | update_protections(current->mm); | ||
1542 | #endif | ||
1538 | } | 1543 | } |
1539 | 1544 | ||
1540 | void *__symbol_get(const char *symbol) | 1545 | void *__symbol_get(const char *symbol) |
diff --git a/mm/nommu.c b/mm/nommu.c index 2d02ca17ce18..1a4473faac48 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
34 | #include <asm/tlb.h> | 34 | #include <asm/tlb.h> |
35 | #include <asm/tlbflush.h> | 35 | #include <asm/tlbflush.h> |
36 | #include <asm/mmu_context.h> | ||
36 | #include "internal.h" | 37 | #include "internal.h" |
37 | 38 | ||
38 | static inline __attribute__((format(printf, 1, 2))) | 39 | static inline __attribute__((format(printf, 1, 2))) |
@@ -623,6 +624,22 @@ static void put_nommu_region(struct vm_region *region) | |||
623 | } | 624 | } |
624 | 625 | ||
625 | /* | 626 | /* |
627 | * update protection on a vma | ||
628 | */ | ||
629 | static void protect_vma(struct vm_area_struct *vma, unsigned long flags) | ||
630 | { | ||
631 | #ifdef CONFIG_MPU | ||
632 | struct mm_struct *mm = vma->vm_mm; | ||
633 | long start = vma->vm_start & PAGE_MASK; | ||
634 | while (start < vma->vm_end) { | ||
635 | protect_page(mm, start, flags); | ||
636 | start += PAGE_SIZE; | ||
637 | } | ||
638 | update_protections(mm); | ||
639 | #endif | ||
640 | } | ||
641 | |||
642 | /* | ||
626 | * add a VMA into a process's mm_struct in the appropriate place in the list | 643 | * add a VMA into a process's mm_struct in the appropriate place in the list |
627 | * and tree and add to the address space's page tree also if not an anonymous | 644 | * and tree and add to the address space's page tree also if not an anonymous |
628 | * page | 645 | * page |
@@ -641,6 +658,8 @@ static void add_vma_to_mm(struct mm_struct *mm, struct vm_area_struct *vma) | |||
641 | mm->map_count++; | 658 | mm->map_count++; |
642 | vma->vm_mm = mm; | 659 | vma->vm_mm = mm; |
643 | 660 | ||
661 | protect_vma(vma, vma->vm_flags); | ||
662 | |||
644 | /* add the VMA to the mapping */ | 663 | /* add the VMA to the mapping */ |
645 | if (vma->vm_file) { | 664 | if (vma->vm_file) { |
646 | mapping = vma->vm_file->f_mapping; | 665 | mapping = vma->vm_file->f_mapping; |
@@ -703,6 +722,8 @@ static void delete_vma_from_mm(struct vm_area_struct *vma) | |||
703 | 722 | ||
704 | kenter("%p", vma); | 723 | kenter("%p", vma); |
705 | 724 | ||
725 | protect_vma(vma, 0); | ||
726 | |||
706 | mm->map_count--; | 727 | mm->map_count--; |
707 | if (mm->mmap_cache == vma) | 728 | if (mm->mmap_cache == vma) |
708 | mm->mmap_cache = NULL; | 729 | mm->mmap_cache = NULL; |