Commit e3885f71 authored by Dave Airlie's avatar Dave Airlie Committed by Danilo Krummrich

nouveau/u_memcpya: use vmemdup_user

I think there are limit checks in place for most things but the
new uAPI wants to not have them.

Add a limit check and use the vmemdup_user helper instead.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarDanilo Krummrich <dakr@redhat.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230810185020.231135-1-airlied@gmail.com
parent 31499b01
...@@ -189,21 +189,12 @@ u_free(void *addr) ...@@ -189,21 +189,12 @@ u_free(void *addr)
static inline void * static inline void *
u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size)
{ {
void *mem; void __user *userptr = u64_to_user_ptr(user);
void __user *userptr = (void __force __user *)(uintptr_t)user; size_t bytes;
size *= nmemb; if (unlikely(check_mul_overflow(nmemb, size, &bytes)))
return NULL;
mem = kvmalloc(size, GFP_KERNEL); return vmemdup_user(userptr, bytes);
if (!mem)
return ERR_PTR(-ENOMEM);
if (copy_from_user(mem, userptr, size)) {
u_free(mem);
return ERR_PTR(-EFAULT);
}
return mem;
} }
#include <nvif/object.h> #include <nvif/object.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment