metag/uaccess: Check access_ok in strncpy_from_user
authorJames Hogan <james.hogan@imgtec.com>
Tue, 2 May 2017 18:41:06 +0000 (19:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 May 2017 13:44:46 +0000 (15:44 +0200)
commite8a8a6972c5075e6057264c45614d13f9e0307e5
tree39b99fdc2331c3dab1ef829d9ac47a73710c67de
parent9fefcb947ec2c2b6900b4c10aface329af0fd9c5
metag/uaccess: Check access_ok in strncpy_from_user

commit 3a158a62da0673db918b53ac1440845a5b64fd90 upstream.

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: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-metag@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/metag/include/asm/uaccess.h