]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iscsi-target: Fix use-after-free during TPG session shutdown
authorNicholas Bellinger <nab@linux-iscsi.org>
Wed, 22 Jul 2015 07:24:09 +0000 (00:24 -0700)
committerSasha Levin <sasha.levin@oracle.com>
Thu, 27 Aug 2015 17:25:51 +0000 (13:25 -0400)
commit118f2fd7d58df44c3bf830868d70e952ad0d4ecb
treeb97e49a8097a3c78d4e8069fcf197636e87b897c
parentb332d923c390c581ba3498d136bfb5127b67d76a
iscsi-target: Fix use-after-free during TPG session shutdown

[ Upstream commit 417c20a9bdd1e876384127cf096d8ae8b559066c ]

This patch fixes a use-after-free bug in iscsit_release_sessions_for_tpg()
where se_portal_group->session_lock was incorrectly released/re-acquired
while walking the active se_portal_group->tpg_sess_list.

The can result in a NULL pointer dereference when iscsit_close_session()
shutdown happens in the normal path asynchronously to this code, causing
a bogus dereference of an already freed list entry to occur.

To address this bug, walk the session list checking for the same state
as before, but move entries to a local list to avoid dropping the lock
while walking the active list.

As before, signal using iscsi_session->session_restatement=1 for those
list entries to be released locally by iscsit_free_session() code.

Reported-by: Sunilkumar Nadumuttlu <sjn@datera.io>
Cc: Sunilkumar Nadumuttlu <sjn@datera.io>
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/target/iscsi/iscsi_target.c