]> 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:07:36 +0000 (11:07 +0100)
commitd9cbf3ac3eb4a5163d755d37560ca8d96d5473b8
treeb112ddbae97899947a00eb1d225a5f9e12e576e0
parentd29cba8eba0b6e5cb4cc70479021d1a79891c417
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