]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/ib-hfi1-validate-page-aligned-for-a-given-virtual-ad.patch
fixes for 4.4
[thirdparty/kernel/stable-queue.git] / queue-4.19 / ib-hfi1-validate-page-aligned-for-a-given-virtual-ad.patch
1 From 55878a234aca3d92db568618f43d7859b1155f2a Mon Sep 17 00:00:00 2001
2 From: Kamenee Arumugam <kamenee.arumugam@intel.com>
3 Date: Fri, 24 May 2019 11:45:04 -0400
4 Subject: IB/hfi1: Validate page aligned for a given virtual address
5
6 [ Upstream commit 97736f36dbebf2cda2799db3b54717ba5b388255 ]
7
8 User applications can register memory regions for TID buffers that are not
9 aligned on page boundaries. Hfi1 is expected to pin those pages in memory
10 and cache the pages with mmu_rb. The rb tree will fail to insert pages
11 that are not aligned correctly.
12
13 Validate whether a given virtual address is page aligned before pinning.
14
15 Fixes: 7e7a436ecb6e ("staging/hfi1: Add TID entry program function body")
16 Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
17 Signed-off-by: Kamenee Arumugam <kamenee.arumugam@intel.com>
18 Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
19 Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
20 Signed-off-by: Sasha Levin <sashal@kernel.org>
21 ---
22 drivers/infiniband/hw/hfi1/user_exp_rcv.c | 3 +++
23 1 file changed, 3 insertions(+)
24
25 diff --git a/drivers/infiniband/hw/hfi1/user_exp_rcv.c b/drivers/infiniband/hw/hfi1/user_exp_rcv.c
26 index dbe7d14a5c76..4e986ca4dd35 100644
27 --- a/drivers/infiniband/hw/hfi1/user_exp_rcv.c
28 +++ b/drivers/infiniband/hw/hfi1/user_exp_rcv.c
29 @@ -324,6 +324,9 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
30 u32 *tidlist = NULL;
31 struct tid_user_buf *tidbuf;
32
33 + if (!PAGE_ALIGNED(tinfo->vaddr))
34 + return -EINVAL;
35 +
36 tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL);
37 if (!tidbuf)
38 return -ENOMEM;
39 --
40 2.20.1
41