usercopy: Adjust tests to deal with SMAP/PAN
authorKees Cook <keescook@chromium.org>
Mon, 13 Feb 2017 19:25:26 +0000 (11:25 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jun 2017 11:16:27 +0000 (13:16 +0200)
commit51ff10e72fc2448f66ca5c4cec81c4631c8aad30
treebab1727eaee93cd3f4e175f550394f1c74dcd621
parent746d48934f5194232bc572b2e90f2e5490ca622f
usercopy: Adjust tests to deal with SMAP/PAN

commit f5f893c57e37ca730808cb2eee3820abd05e7507 upstream.

Under SMAP/PAN/etc, we cannot write directly to userspace memory, so
this rearranges the test bytes to get written through copy_to_user().
Additionally drops the bad copy_from_user() test that would trigger a
memcpy() against userspace on failure.

[arnd: the test module was added in 3.14, and this backported patch
       should apply cleanly on all version from 3.14 to 4.10.
       The original patch was in 4.11 on top of a context change
       I saw the bug triggered with kselftest on a 4.4.y stable kernel]

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/test_user_copy.c