]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.8.5/target-re-add-missing-scf_ack_kref-assignment-in-v4.1.y.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.8.5 / target-re-add-missing-scf_ack_kref-assignment-in-v4.1.y.patch
1 From 527268df31e57cf2b6d417198717c6d6afdb1e3e Mon Sep 17 00:00:00 2001
2 From: Nicholas Bellinger <nab@linux-iscsi.org>
3 Date: Tue, 4 Oct 2016 16:37:05 -0700
4 Subject: target: Re-add missing SCF_ACK_KREF assignment in v4.1.y
5
6 From: Nicholas Bellinger <nab@linux-iscsi.org>
7
8 commit 527268df31e57cf2b6d417198717c6d6afdb1e3e upstream.
9
10 This patch fixes a regression in >= v4.1.y code where the original
11 SCF_ACK_KREF assignment in target_get_sess_cmd() was dropped upstream
12 in commit 054922bb, but the series for addressing TMR ABORT_TASK +
13 LUN_RESET with fabric session reinstatement in commit febe562c20 still
14 depends on this code in transport_cmd_finish_abort().
15
16 The regression manifests itself as a se_cmd->cmd_kref +1 leak, where
17 ABORT_TASK + LUN_RESET can hang indefinately for a specific I_T session
18 for drivers using SCF_ACK_KREF, resulting in hung kthreads.
19
20 This patch has been verified with v4.1.y code.
21
22 Reported-by: Vaibhav Tandon <vst@datera.io>
23 Tested-by: Vaibhav Tandon <vst@datera.io>
24 Cc: Vaibhav Tandon <vst@datera.io>
25 Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 drivers/target/target_core_transport.c | 4 +++-
30 1 file changed, 3 insertions(+), 1 deletion(-)
31
32 --- a/drivers/target/target_core_transport.c
33 +++ b/drivers/target/target_core_transport.c
34 @@ -2547,8 +2547,10 @@ int target_get_sess_cmd(struct se_cmd *s
35 * fabric acknowledgement that requires two target_put_sess_cmd()
36 * invocations before se_cmd descriptor release.
37 */
38 - if (ack_kref)
39 + if (ack_kref) {
40 kref_get(&se_cmd->cmd_kref);
41 + se_cmd->se_cmd_flags |= SCF_ACK_KREF;
42 + }
43
44 spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
45 if (se_sess->sess_tearing_down) {