arm64: uaccess: consistently check object sizes
authorMark Rutland <mark.rutland@arm.com>
Tue, 7 Feb 2017 12:33:55 +0000 (12:33 +0000)
committerHaibo Chen <haibo.chen@nxp.com>
Thu, 12 Apr 2018 10:46:19 +0000 (18:46 +0800)
commit79f0c4f33a2ea0a1e4a9ebbd8693bb897ae19ecb
treeb483145b43dc210dbd19644a2cfeef42e2fc2d24
parentbebe42f22829db9d332c8aa222455cc11ff6c195
arm64: uaccess: consistently check object sizes

commit 76624175dca upstream.

Currently in arm64's copy_{to,from}_user, we only check the
source/destination object size if access_ok() tells us the user access
is permissible.

However, in copy_from_user() we'll subsequently zero any remainder on
the destination object. If we failed the access_ok() check, that applies
to the whole object size, which we didn't check.

To ensure that we catch that case, this patch hoists check_object_size()
to the start of copy_from_user(), matching __copy_from_user() and
__copy_to_user(). To make all of our uaccess copy primitives consistent,
the same is done to copy_to_user().

Cc: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Alex Shi <alex.shi@linaro.org>
arch/arm64/include/asm/uaccess.h