RDMA/ucma: Fix use-after-free access in ucma_close
authorLeon Romanovsky <leonro@mellanox.com>
Mon, 19 Mar 2018 12:20:15 +0000 (14:20 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 31 May 2018 23:30:23 +0000 (00:30 +0100)
commite78759ba4d27ab2f19b285f666887bf4d00b7514
treed36c126e036dd676dda92369fad59a6ee214be3e
parent25272b0d0d1e37d75b7481951c6a28c8c4d515c7
RDMA/ucma: Fix use-after-free access in ucma_close

commit ed65a4dc22083e73bac599ded6a262318cad7baf upstream.

The error in ucma_create_id() left ctx in the list of contexts belong
to ucma file descriptor. The attempt to close this file descriptor causes
to use-after-free accesses while iterating over such list.

Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
Reported-by: <syzbot+dcfd344365a56fbebd0f@syzkaller.appspotmail.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/infiniband/core/ucma.c