Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument of the user address range verification function since we got rid of the old racy i386-only code to walk page tables by hand. It existed because the original 80386 would not honor the write protect bit when in kernel mode, so you had to do COW by hand before doing any user access. But we haven't supported that in a long time, and these days the 'type' argument is a purely historical artifact. A discussion about extending 'user_access_begin()' to do the range checking resulted this patch, because there is no way we're going to move the old VERIFY_xyz interface to that model. And it's best done at the end of the merge window when I've done most of my merges, so let's just get this done once and for all. This patch was mostly done with a sed-script, with manual fix-ups for the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form. There were a couple of notable cases: - csky still had the old "verify_area()" name as an alias. - the iter_iov code had magical hardcoded knowledge of the actual values of VERIFY_{READ,WRITE} (not that they mattered, since nothing really used it) - microblaze used the type argument for a debug printout but other than those oddities this should be a total no-op patch. I tried to fix up all architectures, did fairly extensive grepping for access_ok() uses, and the changes are trivial, but I may have missed something. Any missed conversion should be trivially fixable, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -1282,8 +1282,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
|
||||
if (args->size == 0)
|
||||
return 0;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE,
|
||||
u64_to_user_ptr(args->data_ptr),
|
||||
if (!access_ok(u64_to_user_ptr(args->data_ptr),
|
||||
args->size))
|
||||
return -EFAULT;
|
||||
|
||||
@@ -1609,9 +1608,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
|
||||
if (args->size == 0)
|
||||
return 0;
|
||||
|
||||
if (!access_ok(VERIFY_READ,
|
||||
u64_to_user_ptr(args->data_ptr),
|
||||
args->size))
|
||||
if (!access_ok(u64_to_user_ptr(args->data_ptr), args->size))
|
||||
return -EFAULT;
|
||||
|
||||
obj = i915_gem_object_lookup(file, args->handle);
|
||||
|
@@ -1447,7 +1447,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
|
||||
* to read. However, if the array is not writable the user loses
|
||||
* the updated relocation values.
|
||||
*/
|
||||
if (unlikely(!access_ok(VERIFY_READ, urelocs, remain*sizeof(*urelocs))))
|
||||
if (unlikely(!access_ok(urelocs, remain*sizeof(*urelocs))))
|
||||
return -EFAULT;
|
||||
|
||||
do {
|
||||
@@ -1554,7 +1554,7 @@ static int check_relocations(const struct drm_i915_gem_exec_object2 *entry)
|
||||
|
||||
addr = u64_to_user_ptr(entry->relocs_ptr);
|
||||
size *= sizeof(struct drm_i915_gem_relocation_entry);
|
||||
if (!access_ok(VERIFY_READ, addr, size))
|
||||
if (!access_ok(addr, size))
|
||||
return -EFAULT;
|
||||
|
||||
end = addr + size;
|
||||
@@ -2090,7 +2090,7 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args,
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
user = u64_to_user_ptr(args->cliprects_ptr);
|
||||
if (!access_ok(VERIFY_READ, user, nfences * sizeof(*user)))
|
||||
if (!access_ok(user, nfences * sizeof(*user)))
|
||||
return ERR_PTR(-EFAULT);
|
||||
|
||||
fences = kvmalloc_array(nfences, sizeof(*fences),
|
||||
|
@@ -789,8 +789,7 @@ i915_gem_userptr_ioctl(struct drm_device *dev,
|
||||
if (offset_in_page(args->user_ptr | args->user_size))
|
||||
return -EINVAL;
|
||||
|
||||
if (!access_ok(args->flags & I915_USERPTR_READ_ONLY ? VERIFY_READ : VERIFY_WRITE,
|
||||
(char __user *)(unsigned long)args->user_ptr, args->user_size))
|
||||
if (!access_ok((char __user *)(unsigned long)args->user_ptr, args->user_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (args->flags & I915_USERPTR_READ_ONLY) {
|
||||
|
@@ -52,7 +52,7 @@ static int compat_i915_getparam(struct file *file, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
|
||||
request = compat_alloc_user_space(sizeof(*request));
|
||||
if (!access_ok(VERIFY_WRITE, request, sizeof(*request)) ||
|
||||
if (!access_ok(request, sizeof(*request)) ||
|
||||
__put_user(req32.param, &request->param) ||
|
||||
__put_user((void __user *)(unsigned long)req32.value,
|
||||
&request->value))
|
||||
|
@@ -3052,7 +3052,7 @@ static struct i915_oa_reg *alloc_oa_regs(struct drm_i915_private *dev_priv,
|
||||
if (!n_regs)
|
||||
return NULL;
|
||||
|
||||
if (!access_ok(VERIFY_READ, regs, n_regs * sizeof(u32) * 2))
|
||||
if (!access_ok(regs, n_regs * sizeof(u32) * 2))
|
||||
return ERR_PTR(-EFAULT);
|
||||
|
||||
/* No is_valid function means we're not allowing any register to be programmed. */
|
||||
|
@@ -46,7 +46,7 @@ static int query_topology_info(struct drm_i915_private *dev_priv,
|
||||
if (topo.flags != 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!access_ok(VERIFY_WRITE, u64_to_user_ptr(query_item->data_ptr),
|
||||
if (!access_ok(u64_to_user_ptr(query_item->data_ptr),
|
||||
total_length))
|
||||
return -EFAULT;
|
||||
|
||||
|
Reference in New Issue
Block a user