Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2015941imm; Thu, 24 May 2018 04:33:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpD5RFltcgGBOUmg8LM8VuHI6vy9pQqEW2gkd2ytuBumHWjOcvgrUD/ERC1scxSXUV59LF6 X-Received: by 2002:a63:7804:: with SMTP id t4-v6mr5688098pgc.323.1527161626525; Thu, 24 May 2018 04:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161626; cv=none; d=google.com; s=arc-20160816; b=fSrCzRsOHcrM1FYdWZI/7lcRVa32f/Xs5UYXF31fDskoz1Iy2brSUq5TMiKaFuBCcV OuyVd8nSM89vQGqXKoRpQK2nJ3Uix0h7OgPjpRteb1z2N2aNddyAzb1yVJGNjrLA8v+f R8aVQUlmC5HDQHXIcWWgxn7Gaohapq90uAGsztAFlj7/QRtb6t46ZJh5J17jR2LrOG0/ 54RPOdklYJ8PJcCb3bTS1xTkiXRByQmIy68UrhkuR09VU6X04x6e5oFqkSf6DLRTZbMB gFPF4zhOCQL4djjrYerRhv8aE4StmwqyjM3CJUVNFOnO6qGO19G6G7pQ6jt+M1EHGbQp PU1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=YHSfPFdhIG+Qiy6P1cT1Wjm0pvpXYiwroEFjmpgAchE=; b=PSpm7U5Z5ej1sqKrzaS9gpsGFRjOH+oNxsZ/QmZb+Co0zhJDwEgBm0Ezcq5uuCK9ll GMIT09gCWbhB2MzDmLbeXYrY5jsuB9GXQuukNFSIdZnZ+Wf2fdEaJ/Kwt6XVwpYqeBQc qjBv/ZSOsOcgDOJ07lXDuDtWyNmCxVcZWP6bFLY8yBD+mi1EaW0Eb+KnhVVJee5NxPUA 9eLN3wL0gjrKWBYn6Ay38slwRe9LvlQGXIzpy0dLmdhdgUd64ptRhucClJUGdpeGUE5a q4bJXNcnOPzKMQmyf8uAgA9IHeCf/YBuEo9YrBNPyayKqOpAZrmp5VudtPh9bGTmRn+H zqBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vgzwtll5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10-v6si16682480pgv.109.2018.05.24.04.33.31; Thu, 24 May 2018 04:33:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vgzwtll5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968972AbeEXLbr (ORCPT + 99 others); Thu, 24 May 2018 07:31:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:43194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967616AbeEXJut (ORCPT ); Thu, 24 May 2018 05:50:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F974208AE; Thu, 24 May 2018 09:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155448; bh=fzcS9/JOYJC2b1PhCmI9uJ93d9AiCLwnSfndnV1JBDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vgzwtll5tYbWTGN9jUTtqPqQZWSB9ACgggHtmbcToxnNFPFv8/Ih4/NrfTiHoxilD +HikgJMSV1bdj5KDlxxiywGSXRBibUPT6/hS5M4s3dzYrvrPvWRBeJ1zMJ6G0acFOc r/wABsCCIw4ywZxmZtlxqya/26xOsrnjjD8zohKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Carroll , Raghava Aditya Renukunta , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 62/96] scsi: aacraid: Insure command thread is not recursively stopped Date: Thu, 24 May 2018 11:38:45 +0200 Message-Id: <20180524093609.028038084@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Carroll [ Upstream commit 1c6b41fb92936fa5facea464d5d7cbf855966d04 ] If a recursive IOP_RESET is invoked, usually due to the eh_thread handling errors after the first reset, be sure we flag that the command thread has been stopped to avoid an Oops of the form; [ 336.620256] CPU: 28 PID: 1193 Comm: scsi_eh_0 Kdump: loaded Not tainted 4.14.0-49.el7a.ppc64le #1 [ 336.620297] task: c000003fd630b800 task.stack: c000003fd61a4000 [ 336.620326] NIP: c000000000176794 LR: c00000000013038c CTR: c00000000024bc10 [ 336.620361] REGS: c000003fd61a7720 TRAP: 0300 Not tainted (4.14.0-49.el7a.ppc64le) [ 336.620395] MSR: 9000000000009033 CR: 22084022 XER: 20040000 [ 336.620435] CFAR: c000000000130388 DAR: 0000000000000000 DSISR: 40000000 SOFTE: 1 [ 336.620435] GPR00: c00000000013038c c000003fd61a79a0 c0000000014c7e00 0000000000000000 [ 336.620435] GPR04: 000000000000000c 000000000000000c 9000000000009033 0000000000000477 [ 336.620435] GPR08: 0000000000000477 0000000000000000 0000000000000000 c008000010f7d940 [ 336.620435] GPR12: c00000000024bc10 c000000007a33400 c0000000001708a8 c000003fe3b881d8 [ 336.620435] GPR16: c000003fe3b88060 c000003fd61a7d10 fffffffffffff000 000000000000001e [ 336.620435] GPR20: 0000000000000001 c000000000ebf1a0 0000000000000001 c000003fe3b88000 [ 336.620435] GPR24: 0000000000000003 0000000000000002 c000003fe3b88840 c000003fe3b887e8 [ 336.620435] GPR28: c000003fe3b88000 c000003fc8181788 0000000000000000 c000003fc8181700 [ 336.620750] NIP [c000000000176794] exit_creds+0x34/0x160 [ 336.620775] LR [c00000000013038c] __put_task_struct+0x8c/0x1f0 [ 336.620804] Call Trace: [ 336.620817] [c000003fd61a79a0] [c000003fe3b88000] 0xc000003fe3b88000 (unreliable) [ 336.620853] [c000003fd61a79d0] [c00000000013038c] __put_task_struct+0x8c/0x1f0 [ 336.620889] [c000003fd61a7a00] [c000000000171418] kthread_stop+0x1e8/0x1f0 [ 336.620922] [c000003fd61a7a40] [c008000010f7448c] aac_reset_adapter+0x14c/0x8d0 [aacraid] [ 336.620959] [c000003fd61a7b00] [c008000010f60174] aac_eh_host_reset+0x84/0x100 [aacraid] [ 336.621010] [c000003fd61a7b30] [c000000000864f24] scsi_try_host_reset+0x74/0x180 [ 336.621046] [c000003fd61a7bb0] [c000000000867ac0] scsi_eh_ready_devs+0xc00/0x14d0 [ 336.625165] [c000003fd61a7ca0] [c0000000008699e0] scsi_error_handler+0x550/0x730 [ 336.632101] [c000003fd61a7dc0] [c000000000170a08] kthread+0x168/0x1b0 [ 336.639031] [c000003fd61a7e30] [c00000000000b528] ret_from_kernel_thread+0x5c/0xb4 [ 336.645971] Instruction dump: [ 336.648743] 384216a0 7c0802a6 fbe1fff8 f8010010 f821ffd1 7c7f1b78 60000000 60000000 [ 336.657056] 39400000 e87f0838 f95f0838 7c0004ac <7d401828> 314affff 7d40192d 40c2fff4 [ 336.663997] -[ end trace 4640cf8d4945ad95 ]- So flag when the thread is stopped by setting the thread pointer to NULL. Signed-off-by: Dave Carroll Reviewed-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/aacraid/commsup.c | 4 +++- drivers/scsi/aacraid/linit.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1374,9 +1374,10 @@ static int _aac_reset_adapter(struct aac host = aac->scsi_host_ptr; scsi_block_requests(host); aac_adapter_disable_int(aac); - if (aac->thread->pid != current->pid) { + if (aac->thread && aac->thread->pid != current->pid) { spin_unlock_irq(host->host_lock); kthread_stop(aac->thread); + aac->thread = NULL; jafo = 1; } @@ -1445,6 +1446,7 @@ static int _aac_reset_adapter(struct aac aac->name); if (IS_ERR(aac->thread)) { retval = PTR_ERR(aac->thread); + aac->thread = NULL; goto out; } } --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1083,6 +1083,7 @@ static void __aac_shutdown(struct aac_de up(&fib->event_wait); } kthread_stop(aac->thread); + aac->thread = NULL; } aac_adapter_disable_int(aac); cpu = cpumask_first(cpu_online_mask);