]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
IB/hfi1: Validate page aligned for a given virtual address
authorKamenee Arumugam <kamenee.arumugam@intel.com>
Fri, 24 May 2019 15:45:04 +0000 (11:45 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jun 2019 03:34:49 +0000 (11:34 +0800)
[ Upstream commit 97736f36dbebf2cda2799db3b54717ba5b388255 ]

User applications can register memory regions for TID buffers that are not
aligned on page boundaries. Hfi1 is expected to pin those pages in memory
and cache the pages with mmu_rb. The rb tree will fail to insert pages
that are not aligned correctly.

Validate whether a given virtual address is page aligned before pinning.

Fixes: 7e7a436ecb6e ("staging/hfi1: Add TID entry program function body")
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Kamenee Arumugam <kamenee.arumugam@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/hfi1/user_exp_rcv.c

index 0cd71ce7cc71f767fef7865049bdd09cb5cc0e0f..3592a9ec155e85b686dfaf68e87d8e006550d8bc 100644 (file)
@@ -324,6 +324,9 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd,
        u32 *tidlist = NULL;
        struct tid_user_buf *tidbuf;
 
+       if (!PAGE_ALIGNED(tinfo->vaddr))
+               return -EINVAL;
+
        tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL);
        if (!tidbuf)
                return -ENOMEM;