diff options
| author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-21 04:14:55 -0400 |
|---|---|---|
| committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-21 04:14:55 -0400 |
| commit | db8c076b9206ea35b1f7299708d5510b17674db2 (patch) | |
| tree | 7a5ee32db0c25bb29598c7c300ce7f2680f533a9 /kernel/compat.c | |
| parent | af6261031317f646d22f994c0b467521e47aa49f (diff) | |
| parent | b30a3f6257ed2105259b404d419b4964e363928c (diff) | |
Merge remote branch 'linus' into drm-intel-fixes
Diffstat (limited to 'kernel/compat.c')
| -rw-r--r-- | kernel/compat.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index e167efce8423..c9e2ec0b34a8 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
| @@ -1126,3 +1126,24 @@ compat_sys_sysinfo(struct compat_sysinfo __user *info) | |||
| 1126 | 1126 | ||
| 1127 | return 0; | 1127 | return 0; |
| 1128 | } | 1128 | } |
| 1129 | |||
| 1130 | /* | ||
| 1131 | * Allocate user-space memory for the duration of a single system call, | ||
| 1132 | * in order to marshall parameters inside a compat thunk. | ||
| 1133 | */ | ||
| 1134 | void __user *compat_alloc_user_space(unsigned long len) | ||
| 1135 | { | ||
| 1136 | void __user *ptr; | ||
| 1137 | |||
| 1138 | /* If len would occupy more than half of the entire compat space... */ | ||
| 1139 | if (unlikely(len > (((compat_uptr_t)~0) >> 1))) | ||
| 1140 | return NULL; | ||
| 1141 | |||
| 1142 | ptr = arch_compat_alloc_user_space(len); | ||
| 1143 | |||
| 1144 | if (unlikely(!access_ok(VERIFY_WRITE, ptr, len))) | ||
| 1145 | return NULL; | ||
| 1146 | |||
| 1147 | return ptr; | ||
| 1148 | } | ||
| 1149 | EXPORT_SYMBOL_GPL(compat_alloc_user_space); | ||
