]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tee: Prevent size calculation wraparound on 32-bit kernels
authorJann Horn <jannh@google.com>
Mon, 28 Apr 2025 13:06:43 +0000 (15:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:33 +0000 (11:05 +0100)
commitdd89a7e18c9cd06e35548643af0eee4bb1b85e1e
tree4302b6148723b54c77cedb2c07a127cfae2f2652
parenta5cc6ccac4d95ccd132ca19d6d336a0e4a4b6874
tee: Prevent size calculation wraparound on 32-bit kernels

[ Upstream commit 39bb67edcc582b3b386a9ec983da67fa8a10ec03 ]

The current code around TEE_IOCTL_PARAM_SIZE() is a bit wrong on
32-bit kernels: Multiplying a user-provided 32-bit value with the
size of a structure can wrap around on such platforms.

Fix it by using saturating arithmetic for the size calculation.

This has no security consequences because, in all users of
TEE_IOCTL_PARAM_SIZE(), the subsequent kcalloc() implicitly checks
for wrapping.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Rouven Czerwinski <rouven.czerwinski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tee/tee_core.c