diff options
author | Greg Ungerer <gerg@snapgear.com> | 2005-09-11 21:18:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-11 23:43:47 -0400 |
commit | 66aa2b4b1cf9a61f1550251c56fc6f0d48287591 (patch) | |
tree | b372d102e0f6a8071c2473c84343f7a1a9d4cf94 /mm/nommu.c | |
parent | 966cdb2fdf1776392c98f7d38e0eb9c6dd1c4715 (diff) |
[PATCH] uclinux: add NULL check, 0 end valid check and some more exports to nommu.c
Move call to get_mm_counter() in update_mem_hiwater() to be
inside the check for tsk->mm being null. Otherwise you can be
following a null pointer here. This patch submitted by
Javier Herrero <jherrero@hvsistemas.es>.
Modify the end check for munmap regions to allow for the
legacy behavior of 0 being valid. Pretty much all current
uClinux system libc malloc's pass in 0 as the end point.
A hard check will fail on these, so change the check so
that if it is non-zero it must be valid otherwise it fails.
A passed in value will always succeed (as it used too).
Also export a few more mm system functions - to be consistent
with the VM code exports.
Signed-off-by: Greg Ungerer <gerg@uclinux.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/nommu.c')
-rw-r--r-- | mm/nommu.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index fd4e8df0f02d..064d70442895 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -57,6 +57,11 @@ DECLARE_RWSEM(nommu_vma_sem); | |||
57 | struct vm_operations_struct generic_file_vm_ops = { | 57 | struct vm_operations_struct generic_file_vm_ops = { |
58 | }; | 58 | }; |
59 | 59 | ||
60 | EXPORT_SYMBOL(vmalloc); | ||
61 | EXPORT_SYMBOL(vfree); | ||
62 | EXPORT_SYMBOL(vmalloc_to_page); | ||
63 | EXPORT_SYMBOL(vmalloc_32); | ||
64 | |||
60 | /* | 65 | /* |
61 | * Handle all mappings that got truncated by a "truncate()" | 66 | * Handle all mappings that got truncated by a "truncate()" |
62 | * system call. | 67 | * system call. |
@@ -142,6 +147,8 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, | |||
142 | return(i); | 147 | return(i); |
143 | } | 148 | } |
144 | 149 | ||
150 | EXPORT_SYMBOL(get_user_pages); | ||
151 | |||
145 | DEFINE_RWLOCK(vmlist_lock); | 152 | DEFINE_RWLOCK(vmlist_lock); |
146 | struct vm_struct *vmlist; | 153 | struct vm_struct *vmlist; |
147 | 154 | ||
@@ -852,7 +859,7 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
852 | error_getting_vma: | 859 | error_getting_vma: |
853 | up_write(&nommu_vma_sem); | 860 | up_write(&nommu_vma_sem); |
854 | kfree(vml); | 861 | kfree(vml); |
855 | printk("Allocation of vml for %lu byte allocation from process %d failed\n", | 862 | printk("Allocation of vma for %lu byte allocation from process %d failed\n", |
856 | len, current->pid); | 863 | len, current->pid); |
857 | show_free_areas(); | 864 | show_free_areas(); |
858 | return -ENOMEM; | 865 | return -ENOMEM; |
@@ -909,7 +916,7 @@ int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len) | |||
909 | 916 | ||
910 | for (parent = &mm->context.vmlist; *parent; parent = &(*parent)->next) | 917 | for (parent = &mm->context.vmlist; *parent; parent = &(*parent)->next) |
911 | if ((*parent)->vma->vm_start == addr && | 918 | if ((*parent)->vma->vm_start == addr && |
912 | (*parent)->vma->vm_end == end) | 919 | ((len == 0) || ((*parent)->vma->vm_end == end))) |
913 | goto found; | 920 | goto found; |
914 | 921 | ||
915 | printk("munmap of non-mmaped memory by process %d (%s): %p\n", | 922 | printk("munmap of non-mmaped memory by process %d (%s): %p\n", |
@@ -1054,7 +1061,8 @@ struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr) | |||
1054 | int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, | 1061 | int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, |
1055 | unsigned long to, unsigned long size, pgprot_t prot) | 1062 | unsigned long to, unsigned long size, pgprot_t prot) |
1056 | { | 1063 | { |
1057 | return -EPERM; | 1064 | vma->vm_start = vma->vm_pgoff << PAGE_SHIFT; |
1065 | return 0; | ||
1058 | } | 1066 | } |
1059 | 1067 | ||
1060 | void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) | 1068 | void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) |
@@ -1073,9 +1081,10 @@ void arch_unmap_area(struct mm_struct *mm, unsigned long addr) | |||
1073 | 1081 | ||
1074 | void update_mem_hiwater(struct task_struct *tsk) | 1082 | void update_mem_hiwater(struct task_struct *tsk) |
1075 | { | 1083 | { |
1076 | unsigned long rss = get_mm_counter(tsk->mm, rss); | 1084 | unsigned long rss; |
1077 | 1085 | ||
1078 | if (likely(tsk->mm)) { | 1086 | if (likely(tsk->mm)) { |
1087 | rss = get_mm_counter(tsk->mm, rss); | ||
1079 | if (tsk->mm->hiwater_rss < rss) | 1088 | if (tsk->mm->hiwater_rss < rss) |
1080 | tsk->mm->hiwater_rss = rss; | 1089 | tsk->mm->hiwater_rss = rss; |
1081 | if (tsk->mm->hiwater_vm < tsk->mm->total_vm) | 1090 | if (tsk->mm->hiwater_vm < tsk->mm->total_vm) |