diff options
author | Haggai Abramovsky <hagaya@mellanox.com> | 2016-01-14 12:12:56 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-01-21 12:01:08 -0500 |
commit | dfbee8598d24668b882bcc97d28d5108441cc88a (patch) | |
tree | fa0658b0b454eb0d4d6b1999ec60a3c27a439ca8 | |
parent | 2deeb4772971e56d5bdac0bd3375d5eadaa827fd (diff) |
IB/mlx5: Fix data validation in mlx5_ib_alloc_ucontext
The wrong buffer size was passed to ib_is_udata_cleared.
Signed-off-by: Haggai Abramovsky <hagaya@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index f509dcb85665..f82336699c3e 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -845,6 +845,9 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
845 | if (!dev->ib_active) | 845 | if (!dev->ib_active) |
846 | return ERR_PTR(-EAGAIN); | 846 | return ERR_PTR(-EAGAIN); |
847 | 847 | ||
848 | if (udata->inlen < sizeof(struct ib_uverbs_cmd_hdr)) | ||
849 | return ERR_PTR(-EINVAL); | ||
850 | |||
848 | reqlen = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr); | 851 | reqlen = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr); |
849 | if (reqlen == sizeof(struct mlx5_ib_alloc_ucontext_req)) | 852 | if (reqlen == sizeof(struct mlx5_ib_alloc_ucontext_req)) |
850 | ver = 0; | 853 | ver = 0; |
@@ -871,7 +874,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
871 | 874 | ||
872 | if (reqlen > sizeof(req) && | 875 | if (reqlen > sizeof(req) && |
873 | !ib_is_udata_cleared(udata, sizeof(req), | 876 | !ib_is_udata_cleared(udata, sizeof(req), |
874 | udata->inlen - sizeof(req))) | 877 | reqlen - sizeof(req))) |
875 | return ERR_PTR(-EOPNOTSUPP); | 878 | return ERR_PTR(-EOPNOTSUPP); |
876 | 879 | ||
877 | req.total_num_uuars = ALIGN(req.total_num_uuars, | 880 | req.total_num_uuars = ALIGN(req.total_num_uuars, |