diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-04-15 03:35:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-04-15 03:36:16 -0400 |
commit | b257c14ceb1194a6181144210056d38f22127189 (patch) | |
tree | c803925f1d5bf2237e7495d306bf43929df0c952 /mm/util.c | |
parent | 371fd7e7a56a5c136d31aa980011bd2f131c3ef5 (diff) | |
parent | 2ba3abd8186f24c7fb418927025b4e2120e3a362 (diff) |
Merge branch 'linus' into sched/core
Merge reason: merge the latest fixes, update to -rc4.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -186,6 +186,27 @@ void kzfree(const void *p) | |||
186 | } | 186 | } |
187 | EXPORT_SYMBOL(kzfree); | 187 | EXPORT_SYMBOL(kzfree); |
188 | 188 | ||
189 | int kern_ptr_validate(const void *ptr, unsigned long size) | ||
190 | { | ||
191 | unsigned long addr = (unsigned long)ptr; | ||
192 | unsigned long min_addr = PAGE_OFFSET; | ||
193 | unsigned long align_mask = sizeof(void *) - 1; | ||
194 | |||
195 | if (unlikely(addr < min_addr)) | ||
196 | goto out; | ||
197 | if (unlikely(addr > (unsigned long)high_memory - size)) | ||
198 | goto out; | ||
199 | if (unlikely(addr & align_mask)) | ||
200 | goto out; | ||
201 | if (unlikely(!kern_addr_valid(addr))) | ||
202 | goto out; | ||
203 | if (unlikely(!kern_addr_valid(addr + size - 1))) | ||
204 | goto out; | ||
205 | return 1; | ||
206 | out: | ||
207 | return 0; | ||
208 | } | ||
209 | |||
189 | /* | 210 | /* |
190 | * strndup_user - duplicate an existing string from user space | 211 | * strndup_user - duplicate an existing string from user space |
191 | * @s: The string to duplicate | 212 | * @s: The string to duplicate |