Commit 66aa2b4b1cf9a61f1550251c56fc6f0d48287591
Committed by
Linus Torvalds
1 parent
966cdb2fdf
Exists in
master
and in
7 other branches
[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>
Showing 1 changed file with 13 additions and 4 deletions Side-by-side Diff
mm/nommu.c
... | ... | @@ -57,6 +57,11 @@ |
57 | 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 | 66 | * Handle all mappings that got truncated by a "truncate()" |
62 | 67 | * system call. |
... | ... | @@ -142,6 +147,8 @@ |
142 | 147 | return(i); |
143 | 148 | } |
144 | 149 | |
150 | +EXPORT_SYMBOL(get_user_pages); | |
151 | + | |
145 | 152 | DEFINE_RWLOCK(vmlist_lock); |
146 | 153 | struct vm_struct *vmlist; |
147 | 154 | |
... | ... | @@ -852,7 +859,7 @@ |
852 | 859 | error_getting_vma: |
853 | 860 | up_write(&nommu_vma_sem); |
854 | 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 | 863 | len, current->pid); |
857 | 864 | show_free_areas(); |
858 | 865 | return -ENOMEM; |
... | ... | @@ -909,7 +916,7 @@ |
909 | 916 | |
910 | 917 | for (parent = &mm->context.vmlist; *parent; parent = &(*parent)->next) |
911 | 918 | if ((*parent)->vma->vm_start == addr && |
912 | - (*parent)->vma->vm_end == end) | |
919 | + ((len == 0) || ((*parent)->vma->vm_end == end))) | |
913 | 920 | goto found; |
914 | 921 | |
915 | 922 | printk("munmap of non-mmaped memory by process %d (%s): %p\n", |
... | ... | @@ -1054,7 +1061,8 @@ |
1054 | 1061 | int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, |
1055 | 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 | 1068 | void swap_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) |
1061 | 1069 | |
... | ... | @@ -1073,9 +1081,10 @@ |
1073 | 1081 | |
1074 | 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 | 1086 | if (likely(tsk->mm)) { |
1087 | + rss = get_mm_counter(tsk->mm, rss); | |
1079 | 1088 | if (tsk->mm->hiwater_rss < rss) |
1080 | 1089 | tsk->mm->hiwater_rss = rss; |
1081 | 1090 | if (tsk->mm->hiwater_vm < tsk->mm->total_vm) |