|
10 | 10 | #include <linux/fs.h>
|
11 | 11 | #include <linux/idr.h>
|
12 | 12 | #include <linux/module.h>
|
| 13 | +#include <linux/overflow.h> |
13 | 14 | #include <linux/slab.h>
|
14 | 15 | #include <linux/tee_core.h>
|
15 | 16 | #include <linux/uaccess.h>
|
|
19 | 20 |
|
20 | 21 | #define TEE_NUM_DEVICES 32
|
21 | 22 |
|
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))) |
23 | 24 |
|
24 | 25 | #define TEE_UUID_NS_NAME_SIZE 128
|
25 | 26 |
|
@@ -487,7 +488,7 @@ static int tee_ioctl_open_session(struct tee_context *ctx,
|
487 | 488 | if (copy_from_user(&arg, uarg, sizeof(arg)))
|
488 | 489 | return -EFAULT;
|
489 | 490 |
|
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) |
491 | 492 | return -EINVAL;
|
492 | 493 |
|
493 | 494 | if (arg.num_params) {
|
@@ -565,7 +566,7 @@ static int tee_ioctl_invoke(struct tee_context *ctx,
|
565 | 566 | if (copy_from_user(&arg, uarg, sizeof(arg)))
|
566 | 567 | return -EFAULT;
|
567 | 568 |
|
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) |
569 | 570 | return -EINVAL;
|
570 | 571 |
|
571 | 572 | if (arg.num_params) {
|
@@ -699,7 +700,7 @@ static int tee_ioctl_supp_recv(struct tee_context *ctx,
|
699 | 700 | if (get_user(num_params, &uarg->num_params))
|
700 | 701 | return -EFAULT;
|
701 | 702 |
|
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) |
703 | 704 | return -EINVAL;
|
704 | 705 |
|
705 | 706 | params = kcalloc(num_params, sizeof(struct tee_param), GFP_KERNEL);
|
@@ -798,7 +799,7 @@ static int tee_ioctl_supp_send(struct tee_context *ctx,
|
798 | 799 | get_user(num_params, &uarg->num_params))
|
799 | 800 | return -EFAULT;
|
800 | 801 |
|
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) |
802 | 803 | return -EINVAL;
|
803 | 804 |
|
804 | 805 | params = kcalloc(num_params, sizeof(struct tee_param), GFP_KERNEL);
|
|
0 commit comments