]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: Validate tagged addresses in access_ok() called from kernel threads
authorCatalin Marinas <catalin.marinas@arm.com>
Thu, 5 Dec 2019 13:57:36 +0000 (13:57 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 6 Dec 2019 12:02:56 +0000 (12:02 +0000)
commit0fb965811fa6474ec181574a5be5966d1e005b6f
tree8086aa101be33fd4b519302a6d40050e673fb1b6
parentbd481d317307d5c4fa6adc3782d5cade2b3d6d51
arm64: Validate tagged addresses in access_ok() called from kernel threads

__range_ok(), invoked from access_ok(), clears the tag of the user
address only if CONFIG_ARM64_TAGGED_ADDR_ABI is enabled and the thread
opted in to the relaxed ABI. The latter sets the TIF_TAGGED_ADDR thread
flag. In the case of asynchronous I/O (e.g. io_submit()), the
access_ok() may be called from a kernel thread. Since kernel threads
don't have TIF_TAGGED_ADDR set, access_ok() will fail for valid tagged
user addresses. Example from the ffs_user_copy_worker() thread:

use_mm(io_data->mm);
ret = ffs_copy_to_iter(io_data->buf, ret, &io_data->data);
unuse_mm(io_data->mm);

Relax the __range_ok() check to always untag the user address if called
in the context of a kernel thread. The user pointers would have already
been checked via aio_setup_rw() -> import_{single_range,iovec}() at the
time of the asynchronous I/O request.

Fixes: 35e9e089fde7 ("arm64: Introduce prctl() options to control the tagged user addresses ABI")
Cc: <stable@vger.kernel.org> # 5.4.x-
Cc: Will Deacon <will@kernel.org>
Reported-by: Evgenii Stepanov <eugenis@google.com>
Tested-by: Evgenii Stepanov <eugenis@google.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/uaccess.h