Commit 3a158a62 authored by James Hogan's avatar James Hogan

metag/uaccess: Check access_ok in strncpy_from_user

The metag implementation of strncpy_from_user() doesn't validate the src
pointer, which could allow reading of arbitrary kernel memory. Add a
short access_ok() check to prevent that.

Its still possible for it to read across the user/kernel boundary, but
it will invariably reach a NUL character after only 9 bytes, leaking
only a static kernel address being loaded into D0Re0 at the beginning of
__start, which is acceptable for the immediate fix.
Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
Cc: linux-metag@vger.kernel.org
Cc: stable@vger.kernel.org
parent 8a8b5663
...@@ -199,8 +199,13 @@ do { \ ...@@ -199,8 +199,13 @@ do { \
extern long __must_check __strncpy_from_user(char *dst, const char __user *src, extern long __must_check __strncpy_from_user(char *dst, const char __user *src,
long count); long count);
#define strncpy_from_user(dst, src, count) __strncpy_from_user(dst, src, count) static inline long
strncpy_from_user(char *dst, const char __user *src, long count)
{
if (!access_ok(VERIFY_READ, src, 1))
return -EFAULT;
return __strncpy_from_user(dst, src, count);
}
/* /*
* Return the size of a string (including the ending 0) * Return the size of a string (including the ending 0)
* *
......
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