]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
tcmu: fix crash during device removal
authorMike Christie <mchristi@redhat.com>
Wed, 17 May 2017 09:34:37 +0000 (04:34 -0500)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 24 May 2017 02:50:49 +0000 (19:50 -0700)
commitf3cdbe39b2ab0636dec0d5d43b54f1061ce7566c
tree957000299919ddd60cf9159df3563d21a8ba7be7
parent4ff83daa0200affe1894bd33d17bac404e3d78d4
tcmu: fix crash during device removal

We currently do

tcmu_free_device ->tcmu_netlink_event(TCMU_CMD_REMOVED_DEVICE) ->
uio_unregister_device -> kfree(tcmu_dev).

The problem is that the kernel does not wait for userspace to
do the close() on the uio device before freeing the tcmu_dev.
We can then hit a race where the kernel frees the tcmu_dev before
userspace does close() and so when close() -> release -> tcmu_release
is done, we try to access a freed tcmu_dev.

This patch made over the target-pending master branch moves the freeing
of the tcmu_dev to when the last reference has been dropped.

This also fixes a leak where if tcmu_configure_device was not called on a
device we did not free udev->name which was allocated at tcmu_alloc_device time.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_user.c