Skip to content

Commit 9477c3e

Browse files
committed
Merge tag 'tee-for-v6.16' of https://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee into soc/drivers
Small TEE updates for v6.16 - Remove an unnecessary NULL check before release_firmware() in the OP-TEE driver - Prevent a size wrap in the TEE subsystem. The wrap would have been caught later in the code so no security consequences. * tag 'tee-for-v6.16' of https://git.kernel.org/pub/scm/linux/kernel/git/jenswi/linux-tee: tee: Prevent size calculation wraparound on 32-bit kernels tee: optee: smc: remove unnecessary NULL check before release_firmware() Link: https://lore.kernel.org/r/20250509065114.GA4188600@rayden Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 8575158 + 39bb67e commit 9477c3e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/tee/optee/smc_abi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,8 +1551,7 @@ static int optee_load_fw(struct platform_device *pdev,
15511551
data_pa_high, data_pa_low, 0, 0, 0, &res);
15521552
if (!rc)
15531553
rc = res.a0;
1554-
if (fw)
1555-
release_firmware(fw);
1554+
release_firmware(fw);
15561555
kfree(data_buf);
15571556

15581557
if (!rc) {

drivers/tee/tee_core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/fs.h>
1111
#include <linux/idr.h>
1212
#include <linux/module.h>
13+
#include <linux/overflow.h>
1314
#include <linux/slab.h>
1415
#include <linux/tee_core.h>
1516
#include <linux/uaccess.h>
@@ -19,7 +20,7 @@
1920

2021
#define TEE_NUM_DEVICES 32
2122

22-
#define TEE_IOCTL_PARAM_SIZE(x) (sizeof(struct tee_param) * (x))
23+
#define TEE_IOCTL_PARAM_SIZE(x) (size_mul(sizeof(struct tee_param), (x)))
2324

2425
#define TEE_UUID_NS_NAME_SIZE 128
2526

@@ -487,7 +488,7 @@ static int tee_ioctl_open_session(struct tee_context *ctx,
487488
if (copy_from_user(&arg, uarg, sizeof(arg)))
488489
return -EFAULT;
489490

490-
if (sizeof(arg) + TEE_IOCTL_PARAM_SIZE(arg.num_params) != buf.buf_len)
491+
if (size_add(sizeof(arg), TEE_IOCTL_PARAM_SIZE(arg.num_params)) != buf.buf_len)
491492
return -EINVAL;
492493

493494
if (arg.num_params) {
@@ -565,7 +566,7 @@ static int tee_ioctl_invoke(struct tee_context *ctx,
565566
if (copy_from_user(&arg, uarg, sizeof(arg)))
566567
return -EFAULT;
567568

568-
if (sizeof(arg) + TEE_IOCTL_PARAM_SIZE(arg.num_params) != buf.buf_len)
569+
if (size_add(sizeof(arg), TEE_IOCTL_PARAM_SIZE(arg.num_params)) != buf.buf_len)
569570
return -EINVAL;
570571

571572
if (arg.num_params) {
@@ -699,7 +700,7 @@ static int tee_ioctl_supp_recv(struct tee_context *ctx,
699700
if (get_user(num_params, &uarg->num_params))
700701
return -EFAULT;
701702

702-
if (sizeof(*uarg) + TEE_IOCTL_PARAM_SIZE(num_params) != buf.buf_len)
703+
if (size_add(sizeof(*uarg), TEE_IOCTL_PARAM_SIZE(num_params)) != buf.buf_len)
703704
return -EINVAL;
704705

705706
params = kcalloc(num_params, sizeof(struct tee_param), GFP_KERNEL);
@@ -798,7 +799,7 @@ static int tee_ioctl_supp_send(struct tee_context *ctx,
798799
get_user(num_params, &uarg->num_params))
799800
return -EFAULT;
800801

801-
if (sizeof(*uarg) + TEE_IOCTL_PARAM_SIZE(num_params) > buf.buf_len)
802+
if (size_add(sizeof(*uarg), TEE_IOCTL_PARAM_SIZE(num_params)) > buf.buf_len)
802803
return -EINVAL;
803804

804805
params = kcalloc(num_params, sizeof(struct tee_param), GFP_KERNEL);

0 commit comments

Comments
 (0)