Skip to content

Commit 2adf535

Browse files
committed
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 <[email protected]>
1 parent 9afcc71 commit 2adf535

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

arch/xtensa/include/asm/uaccess.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,15 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
272272
*/
273273

274274
static inline unsigned long
275-
__xtensa_clear_user(void *addr, unsigned long size)
275+
__xtensa_clear_user(void __user *addr, unsigned long size)
276276
{
277-
if (!__memset(addr, 0, size))
277+
if (!__memset((void __force *)addr, 0, size))
278278
return size;
279279
return 0;
280280
}
281281

282282
static inline unsigned long
283-
clear_user(void *addr, unsigned long size)
283+
clear_user(void __user *addr, unsigned long size)
284284
{
285285
if (access_ok(addr, size))
286286
return __xtensa_clear_user(addr, size);
@@ -292,10 +292,10 @@ clear_user(void *addr, unsigned long size)
292292

293293
#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
294294

295-
extern long __strncpy_user(char *, const char *, long);
295+
extern long __strncpy_user(char *dst, const char __user *src, long count);
296296

297297
static inline long
298-
strncpy_from_user(char *dst, const char *src, long count)
298+
strncpy_from_user(char *dst, const char __user *src, long count)
299299
{
300300
if (access_ok(src, 1))
301301
return __strncpy_user(dst, src, count);
@@ -308,13 +308,11 @@ long strncpy_from_user(char *dst, const char *src, long count);
308308
/*
309309
* Return the size of a string (including the ending 0!)
310310
*/
311-
extern long __strnlen_user(const char *, long);
311+
extern long __strnlen_user(const char __user *str, long len);
312312

313-
static inline long strnlen_user(const char *str, long len)
313+
static inline long strnlen_user(const char __user *str, long len)
314314
{
315-
unsigned long top = __kernel_ok ? ~0UL : TASK_SIZE - 1;
316-
317-
if ((unsigned long)str > top)
315+
if (!access_ok(str, 1))
318316
return 0;
319317
return __strnlen_user(str, len);
320318
}

0 commit comments

Comments
 (0)