Skip to contentSkip to conversation

Patch "iscsi-target: Fix initial login PDU asynchronous socket close OOPs" has been added to the 3.18-stable tree

PATCH [email protected] 1 participant 1 message Aug 8, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

iscsi-target: Fix initial login PDU asynchronous socket close OOPs

to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
iscsi-target-fix-initial-login-pdu-asynchronous-socket-close-oops.patch
and it can be found in the queue-3.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 25cdda95fda78d22d44157da15aa7ea34be3c804 Mon Sep 17 00:00:00 2001

From: Nicholas Bellinger <[email protected]>
Date: Wed, 24 May 2017 21:47:09 -0700
Subject: iscsi-target: Fix initial login PDU asynchronous socket close OOPs

From: Nicholas Bellinger <[email protected]>

commit 25cdda95fda78d22d44157da15aa7ea34be3c804 upstream.

This patch fixes a OOPs originally introduced by:

commit bb048357dad6d604520c91586334c9c230366a14
Author: Nicholas Bellinger <[email protected]>
Date: Thu Sep 5 14:54:04 2013 -0700

iscsi-target: Add sk->sk_state_change to cleanup after TCP failure

which would trigger a NULL pointer dereference when a TCP connection was closed asynchronously via iscsi_target_sk_state_change(), but only when the initial PDU processing in iscsi_target_do_login() from iscsi_np process context was blocked waiting for backend I/O to complete.

To address this issue, this patch makes the following changes.

First, it introduces some common helper functions used for checking socket closing state, checking login_flags, and atomically checking socket closing state + setting login_flags.

Second, it introduces a LOGIN_FLAGS_INITIAL_PDU bit to know when a TCP connection has dropped via iscsi_target_sk_state_change(), but the initial PDU processing within iscsi_target_do_login() in iscsi_np context is still running. For this case, it sets LOGIN_FLAGS_CLOSED, but doesn't invoke schedule_delayed_work().

The original NULL pointer dereference case reported by MNC is now handled by iscsi_target_do_login() doing a iscsi_target_sk_check_close() before transitioning to FFP to determine when the socket has already closed, or iscsi_target_start_negotiation() if the login needs to exchange more PDUs (eg: iscsi_target_do_login returned 0) but the socket has closed. For both of these cases, the cleanup up of remaining connection resources will occur in iscsi_target_start_negotiation() from iscsi_np process context once the failure is detected.

Finally, to handle to case where iscsi_target_sk_state_change() is called after the initial PDU procesing is complete, it now invokes conn->login_work -> iscsi_target_do_login_rx() to perform cleanup once existing iscsi_target_sk_check_close() checks detect connection failure. For this case, the cleanup of remaining connection resources will occur in iscsi_target_do_login_rx() from delayed workqueue process context once the failure is detected.

---
 drivers/target/iscsi/iscsi_target_core.h |    1 
 drivers/target/iscsi/iscsi_target_nego.c |  204 ++++++++++++++++++++-----------
 2 files changed, 138 insertions(+), 67 deletions(-)
drivers/target/iscsi/iscsi_target_core.h +1 -0
@@ -562,6 +562,7 @@ struct iscsi_conn {
 #define LOGIN_FLAGS_READ_ACTIVE		1
 #define LOGIN_FLAGS_CLOSED		2
 #define LOGIN_FLAGS_READY		4
+#define LOGIN_FLAGS_INITIAL_PDU		8
 	unsigned long		login_flags;
 	struct delayed_work	login_work;
 	struct delayed_work	login_cleanup_work;
drivers/target/iscsi/iscsi_target_nego.c +137 -67

288 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-3.18/iscsi-target-fix-delayed-logout-processing-greater-than-seconds_for_logout_comp.patch queue-3.18/iscsi-target-always-wait-for-kthread_should_stop-before-kthread-exit.patch queue-3.18/iscsi-target-fix-early-sk_data_ready-login_flags_ready-race.patch queue-3.18/iscsi-target-fix-initial-login-pdu-asynchronous-socket-close-oops.patch queue-3.18/target-avoid-mappedlun-symlink-creation-during-lun-shutdown.patch