generic ...copy_..._user primitives

provide raw_copy_..._user() and select ARCH_HAS_RAW_COPY_USER to use those.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro
2017-03-20 21:56:06 -04:00
parent c1aad8dcc4
commit d597580d37
5 changed files with 229 additions and 0 deletions

View File

@@ -86,7 +86,11 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
static inline int __put_user_fn(size_t size, void __user *ptr, void *x)
{
#ifdef CONFIG_ARCH_HAS_RAW_COPY_USER
return unlikely(raw_copy_to_user(ptr, x, size)) ? -EFAULT : 0;
#else
return unlikely(__copy_to_user(ptr, x, size)) ? -EFAULT : 0;
#endif
}
#define __put_user_fn(sz, u, k) __put_user_fn(sz, u, k)
@@ -147,7 +151,11 @@ extern int __put_user_bad(void) __attribute__((noreturn));
#ifndef __get_user_fn
static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
{
#ifdef CONFIG_ARCH_HAS_RAW_COPY_USER
return unlikely(raw_copy_from_user(x, ptr, size)) ? -EFAULT : 0;
#else
return unlikely(__copy_from_user(x, ptr, size)) ? -EFAULT : 0;
#endif
}
#define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k)
@@ -156,6 +164,8 @@ static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
extern int __get_user_bad(void) __attribute__((noreturn));
#ifndef CONFIG_ARCH_HAS_RAW_COPY_USER
#ifndef __copy_from_user_inatomic
#define __copy_from_user_inatomic __copy_from_user
#endif
@@ -185,6 +195,7 @@ static inline long copy_to_user(void __user *to,
else
return n;
}
#endif
/*
* Copy a null terminated string from userspace.