xtensa: add missing __user annotations to asm/uaccess.h
clear_user, strncpy_user, strnlen_user and their helpers operate on user pointers, but don't have their arguments marked as __user. Add __user annotation to userspace pointers of those functions. Fix open-coded access check in the strnlen_user while at it. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
parent
9afcc71b4f
commit
2adf5352a3
@ -272,15 +272,15 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
__xtensa_clear_user(void *addr, unsigned long size)
|
__xtensa_clear_user(void __user *addr, unsigned long size)
|
||||||
{
|
{
|
||||||
if (!__memset(addr, 0, size))
|
if (!__memset((void __force *)addr, 0, size))
|
||||||
return size;
|
return size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long
|
static inline unsigned long
|
||||||
clear_user(void *addr, unsigned long size)
|
clear_user(void __user *addr, unsigned long size)
|
||||||
{
|
{
|
||||||
if (access_ok(addr, size))
|
if (access_ok(addr, size))
|
||||||
return __xtensa_clear_user(addr, size);
|
return __xtensa_clear_user(addr, size);
|
||||||
@ -292,10 +292,10 @@ clear_user(void *addr, unsigned long size)
|
|||||||
|
|
||||||
#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
|
#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
|
||||||
|
|
||||||
extern long __strncpy_user(char *, const char *, long);
|
extern long __strncpy_user(char *dst, const char __user *src, long count);
|
||||||
|
|
||||||
static inline long
|
static inline long
|
||||||
strncpy_from_user(char *dst, const char *src, long count)
|
strncpy_from_user(char *dst, const char __user *src, long count)
|
||||||
{
|
{
|
||||||
if (access_ok(src, 1))
|
if (access_ok(src, 1))
|
||||||
return __strncpy_user(dst, src, count);
|
return __strncpy_user(dst, src, count);
|
||||||
@ -308,13 +308,11 @@ long strncpy_from_user(char *dst, const char *src, long count);
|
|||||||
/*
|
/*
|
||||||
* Return the size of a string (including the ending 0!)
|
* Return the size of a string (including the ending 0!)
|
||||||
*/
|
*/
|
||||||
extern long __strnlen_user(const char *, long);
|
extern long __strnlen_user(const char __user *str, long len);
|
||||||
|
|
||||||
static inline long strnlen_user(const char *str, long len)
|
static inline long strnlen_user(const char __user *str, long len)
|
||||||
{
|
{
|
||||||
unsigned long top = __kernel_ok ? ~0UL : TASK_SIZE - 1;
|
if (!access_ok(str, 1))
|
||||||
|
|
||||||
if ((unsigned long)str > top)
|
|
||||||
return 0;
|
return 0;
|
||||||
return __strnlen_user(str, len);
|
return __strnlen_user(str, len);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user