diff options
Diffstat (limited to 'arch/x86/kernel/sys_x86_64.c')
-rw-r--r-- | arch/x86/kernel/sys_x86_64.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c index c9288c883e20..6bc211accf08 100644 --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c | |||
@@ -13,16 +13,17 @@ | |||
13 | #include <linux/utsname.h> | 13 | #include <linux/utsname.h> |
14 | #include <linux/personality.h> | 14 | #include <linux/personality.h> |
15 | #include <linux/random.h> | 15 | #include <linux/random.h> |
16 | #include <linux/uaccess.h> | ||
16 | 17 | ||
17 | #include <asm/uaccess.h> | ||
18 | #include <asm/ia32.h> | 18 | #include <asm/ia32.h> |
19 | #include <asm/syscalls.h> | 19 | #include <asm/syscalls.h> |
20 | 20 | ||
21 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, | 21 | asmlinkage long sys_mmap(unsigned long addr, unsigned long len, |
22 | unsigned long fd, unsigned long off) | 22 | unsigned long prot, unsigned long flags, |
23 | unsigned long fd, unsigned long off) | ||
23 | { | 24 | { |
24 | long error; | 25 | long error; |
25 | struct file * file; | 26 | struct file *file; |
26 | 27 | ||
27 | error = -EINVAL; | 28 | error = -EINVAL; |
28 | if (off & ~PAGE_MASK) | 29 | if (off & ~PAGE_MASK) |
@@ -57,9 +58,9 @@ static void find_start_end(unsigned long flags, unsigned long *begin, | |||
57 | unmapped base down for this case. This can give | 58 | unmapped base down for this case. This can give |
58 | conflicts with the heap, but we assume that glibc | 59 | conflicts with the heap, but we assume that glibc |
59 | malloc knows how to fall back to mmap. Give it 1GB | 60 | malloc knows how to fall back to mmap. Give it 1GB |
60 | of playground for now. -AK */ | 61 | of playground for now. -AK */ |
61 | *begin = 0x40000000; | 62 | *begin = 0x40000000; |
62 | *end = 0x80000000; | 63 | *end = 0x80000000; |
63 | if (current->flags & PF_RANDOMIZE) { | 64 | if (current->flags & PF_RANDOMIZE) { |
64 | new_begin = randomize_range(*begin, *begin + 0x02000000, 0); | 65 | new_begin = randomize_range(*begin, *begin + 0x02000000, 0); |
65 | if (new_begin) | 66 | if (new_begin) |
@@ -67,9 +68,9 @@ static void find_start_end(unsigned long flags, unsigned long *begin, | |||
67 | } | 68 | } |
68 | } else { | 69 | } else { |
69 | *begin = TASK_UNMAPPED_BASE; | 70 | *begin = TASK_UNMAPPED_BASE; |
70 | *end = TASK_SIZE; | 71 | *end = TASK_SIZE; |
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
74 | unsigned long | 75 | unsigned long |
75 | arch_get_unmapped_area(struct file *filp, unsigned long addr, | 76 | arch_get_unmapped_area(struct file *filp, unsigned long addr, |
@@ -79,11 +80,11 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
79 | struct vm_area_struct *vma; | 80 | struct vm_area_struct *vma; |
80 | unsigned long start_addr; | 81 | unsigned long start_addr; |
81 | unsigned long begin, end; | 82 | unsigned long begin, end; |
82 | 83 | ||
83 | if (flags & MAP_FIXED) | 84 | if (flags & MAP_FIXED) |
84 | return addr; | 85 | return addr; |
85 | 86 | ||
86 | find_start_end(flags, &begin, &end); | 87 | find_start_end(flags, &begin, &end); |
87 | 88 | ||
88 | if (len > end) | 89 | if (len > end) |
89 | return -ENOMEM; | 90 | return -ENOMEM; |
@@ -97,12 +98,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
97 | } | 98 | } |
98 | if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32)) | 99 | if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32)) |
99 | && len <= mm->cached_hole_size) { | 100 | && len <= mm->cached_hole_size) { |
100 | mm->cached_hole_size = 0; | 101 | mm->cached_hole_size = 0; |
101 | mm->free_area_cache = begin; | 102 | mm->free_area_cache = begin; |
102 | } | 103 | } |
103 | addr = mm->free_area_cache; | 104 | addr = mm->free_area_cache; |
104 | if (addr < begin) | 105 | if (addr < begin) |
105 | addr = begin; | 106 | addr = begin; |
106 | start_addr = addr; | 107 | start_addr = addr; |
107 | 108 | ||
108 | full_search: | 109 | full_search: |
@@ -128,7 +129,7 @@ full_search: | |||
128 | return addr; | 129 | return addr; |
129 | } | 130 | } |
130 | if (addr + mm->cached_hole_size < vma->vm_start) | 131 | if (addr + mm->cached_hole_size < vma->vm_start) |
131 | mm->cached_hole_size = vma->vm_start - addr; | 132 | mm->cached_hole_size = vma->vm_start - addr; |
132 | 133 | ||
133 | addr = vma->vm_end; | 134 | addr = vma->vm_end; |
134 | } | 135 | } |
@@ -178,7 +179,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | |||
178 | vma = find_vma(mm, addr-len); | 179 | vma = find_vma(mm, addr-len); |
179 | if (!vma || addr <= vma->vm_start) | 180 | if (!vma || addr <= vma->vm_start) |
180 | /* remember the address as a hint for next time */ | 181 | /* remember the address as a hint for next time */ |
181 | return (mm->free_area_cache = addr-len); | 182 | return mm->free_area_cache = addr-len; |
182 | } | 183 | } |
183 | 184 | ||
184 | if (mm->mmap_base < len) | 185 | if (mm->mmap_base < len) |
@@ -195,7 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | |||
195 | vma = find_vma(mm, addr); | 196 | vma = find_vma(mm, addr); |
196 | if (!vma || addr+len <= vma->vm_start) | 197 | if (!vma || addr+len <= vma->vm_start) |
197 | /* remember the address as a hint for next time */ | 198 | /* remember the address as a hint for next time */ |
198 | return (mm->free_area_cache = addr); | 199 | return mm->free_area_cache = addr; |
199 | 200 | ||
200 | /* remember the largest hole we saw so far */ | 201 | /* remember the largest hole we saw so far */ |
201 | if (addr + mm->cached_hole_size < vma->vm_start) | 202 | if (addr + mm->cached_hole_size < vma->vm_start) |
@@ -225,13 +226,13 @@ bottomup: | |||
225 | } | 226 | } |
226 | 227 | ||
227 | 228 | ||
228 | asmlinkage long sys_uname(struct new_utsname __user * name) | 229 | asmlinkage long sys_uname(struct new_utsname __user *name) |
229 | { | 230 | { |
230 | int err; | 231 | int err; |
231 | down_read(&uts_sem); | 232 | down_read(&uts_sem); |
232 | err = copy_to_user(name, utsname(), sizeof (*name)); | 233 | err = copy_to_user(name, utsname(), sizeof(*name)); |
233 | up_read(&uts_sem); | 234 | up_read(&uts_sem); |
234 | if (personality(current->personality) == PER_LINUX32) | 235 | if (personality(current->personality) == PER_LINUX32) |
235 | err |= copy_to_user(&name->machine, "i686", 5); | 236 | err |= copy_to_user(&name->machine, "i686", 5); |
236 | return err ? -EFAULT : 0; | 237 | return err ? -EFAULT : 0; |
237 | } | 238 | } |