diff options
author | Yann Droneaud <ydroneaud@opteya.com> | 2013-12-11 17:01:52 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2013-12-20 13:54:33 -0500 |
commit | 6bcca3d4a3bcc9859cf001a0a21c8796edae2dc0 (patch) | |
tree | a577a4d85acbb4fef1b1c4f28929ed12f20310aa /drivers/infiniband/core/uverbs_cmd.c | |
parent | 98a37510ec1452817600d8ea47cff1d9f8d9bec8 (diff) |
IB/uverbs: Check input length in flow steering uverbs
Since ib_copy_from_udata() doesn't check yet the available input data
length before accessing userspace memory, an explicit check of this
length is required to prevent:
- reading past the user provided buffer,
- underflow when subtracting the expected command size from the input
length.
This will ensure the newly added flow steering uverbs don't try to
process truncated commands.
Link: http://marc.info/?i=cover.1386798254.git.ydroneaud@opteya.com>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs_cmd.c')
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 45fb80b876b0..f1cc83855af6 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -2649,6 +2649,9 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, | |||
2649 | void *ib_spec; | 2649 | void *ib_spec; |
2650 | int i; | 2650 | int i; |
2651 | 2651 | ||
2652 | if (ucore->inlen < sizeof(cmd)) | ||
2653 | return -EINVAL; | ||
2654 | |||
2652 | if (ucore->outlen < sizeof(resp)) | 2655 | if (ucore->outlen < sizeof(resp)) |
2653 | return -ENOSPC; | 2656 | return -ENOSPC; |
2654 | 2657 | ||
@@ -2799,6 +2802,9 @@ int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file, | |||
2799 | struct ib_uobject *uobj; | 2802 | struct ib_uobject *uobj; |
2800 | int ret; | 2803 | int ret; |
2801 | 2804 | ||
2805 | if (ucore->inlen < sizeof(cmd)) | ||
2806 | return -EINVAL; | ||
2807 | |||
2802 | ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); | 2808 | ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); |
2803 | if (ret) | 2809 | if (ret) |
2804 | return ret; | 2810 | return ret; |