linux/drivers/infiniband/ulp/ipoib
Erez Shitrit 546481c281 IB/ipoib: Fix memory corruption in ipoib cm mode connect flow
When a new CM connection is being requested, ipoib driver copies data
from the path pointer in the CM/tx object, the path object might be
invalid at the point and memory corruption will happened later when now
the CM driver will try using that data.

The next scenario demonstrates it:
	neigh_add_path --> ipoib_cm_create_tx -->
	queue_work (pointer to path is in the cm/tx struct)
	#while the work is still in the queue,
	#the port goes down and causes the ipoib_flush_paths:
	ipoib_flush_paths --> path_free --> kfree(path)
	#at this point the work scheduled starts.
	ipoib_cm_tx_start --> copy from the (invalid)path pointer:
	(memcpy(&pathrec, &p->path->pathrec, sizeof pathrec);)
	 -> memory corruption.

To fix that the driver now starts the CM/tx connection only if that
specific path exists in the general paths database.
This check is protected with the relevant locks, and uses the gid from
the neigh member in the CM/tx object which is valid according to the ref
count that was taken by the CM/tx.

Fixes: 839fcaba35 ('IPoIB: Connected mode experimental support')
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-09-02 14:07:38 -04:00
..
ipoib_cm.c IB/ipoib: Fix memory corruption in ipoib cm mode connect flow 2016-09-02 14:07:38 -04:00
ipoib_ethtool.c IB/ipoib: Use new device FW version string 2016-06-23 12:08:34 -04:00
ipoib_fs.c IPoIB: Remove unnecessary test for NULL before debugfs_remove() 2014-08-12 21:59:54 -07:00
ipoib_ib.c IB/IPoIB: Disable bottom half when dealing with device address 2016-06-07 09:50:54 -04:00
ipoib_main.c IB/ipoib: Fix memory corruption in ipoib cm mode connect flow 2016-09-02 14:07:38 -04:00
ipoib_multicast.c IB/IPoIB: Disable bottom half when dealing with device address 2016-06-07 09:50:54 -04:00
ipoib_netlink.c infiniband: make sure the src net is infiniband when create new link 2014-01-03 20:38:56 -05:00
ipoib_verbs.c IB/ipoib: Report SG feature regardless of HW UD CSUM capability 2016-08-03 21:03:32 -04:00
ipoib_vlan.c IB/IPoIB: Fix race between ipoib_remove_one to sysfs functions 2016-06-07 09:50:53 -04:00
ipoib.h IB/ipoib: Fix memory corruption in ipoib cm mode connect flow 2016-09-02 14:07:38 -04:00
Kconfig
Makefile IB/ipoib: Add rtnl_link_ops support 2012-09-20 16:49:17 -04:00