IB/security: Restrict use of the write() interface
commita34c1651ea7a55f3c0e77c80c3b27605d5a7dfea
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Mon, 11 Apr 2016 01:13:13 +0000 (10 19:13 -0600)
committerSasha Levin <sasha.levin@oracle.com>
Tue, 17 May 2016 18:51:48 +0000 (17 14:51 -0400)
treee1e61d2510b8e17e447e9f36a3e6a70ac205f131
parentc2cf8eb1284508d30f91ec4f652e18d3c40a3f15
IB/security: Restrict use of the write() interface

[ Upstream commit e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3 ]

The drivers/infiniband stack uses write() as a replacement for
bi-directional ioctl().  This is not safe. There are ways to
trigger write calls that result in the return structure that
is normally written to user space being shunted off to user
specified kernel memory instead.

For the immediate repair, detect and deny suspicious accesses to
the write API.

For long term, update the user space libraries and the kernel API
to something that doesn't present the same security vulnerabilities
(likely a structured ioctl() interface).

The impacted uAPI interfaces are generally only available if
hardware from drivers/infiniband is installed in the system.

Reported-by: Jann Horn <jann@thejh.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
[ Expanded check to all known write() entry points ]
Cc: stable@vger.kernel.org
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/infiniband/core/ucm.c
drivers/infiniband/core/ucma.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/qib/qib_file_ops.c
include/rdma/ib.h