]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/ucma: check fd type in ucma_migrate_id()
authorJann Horn <jannh@google.com>
Mon, 3 Sep 2018 16:54:14 +0000 (18:54 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 4 Sep 2018 21:07:55 +0000 (15:07 -0600)
commit75a0da55913490cdab7ce718345bfce985cf8ed7
tree48ade8d7787f6e7a5e96282ed1711d915dbb086e
parent77e0a4623a7dc6c49e4b731092b7a6d5605e640c
RDMA/ucma: check fd type in ucma_migrate_id()

The current code grabs the private_data of whatever file descriptor
userspace has supplied and implicitly casts it to a `struct ucma_file *`,
potentially causing a type confusion.

This is probably fine in practice because the pointer is only used for
comparisons, it is never actually dereferenced; and even in the
comparisons, it is unlikely that a file from another filesystem would have
a ->private_data pointer that happens to also be valid in this context.
But ->private_data is not always guaranteed to be a valid pointer to an
object owned by the file's filesystem; for example, some filesystems just
cram numbers in there.

Check the type of the supplied file descriptor to be safe, analogous to how
other places in the kernel do it.

Fixes: 31d9d9a4fd72 ("RDMA/cma: add support for rdma_migrate_id()")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/ucma.c