Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1975948imm; Thu, 24 May 2018 03:54:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobu2jTarMyH3oorkVrVU0vCXIa/hdb3nRMpbQNXKxrbGRamReYbDHF5j6R9ZfoSCsPnF/y X-Received: by 2002:a17:902:229:: with SMTP id 38-v6mr6881083plc.384.1527159253453; Thu, 24 May 2018 03:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527159253; cv=none; d=google.com; s=arc-20160816; b=u/eGSFqnsWnoI94Y8YFopmFBseoguKlOdphqZHy98j6XMsG2Z+mMn9OO2pWY8XI5kv 7SSSv9zIMsXGOUpJge7j6YO6x4MbKcxF8rcjHWjYJtHN1Sx11dcwesO0VVT77R5Ug24u 78+jGWtDeb7pYu2ResdEtDDj+hPTPxUyVqKzKpda7tPXgMYIBsMSnfhvbMEFAqte7+JM kCm/tf7B3I1Ii9sbaC34bJujOqpXhsAWyUi9sR8dYpp8h84TJtGSWC7U8Q+GmZ9ubvlh lCYJLSRIAvGTC5lwQEP5/twISfiaKqLnsDQyVTnv6hQDJLXE6BVJL3+jnWgrFe70c3ah +7cw== 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=E1xiqeBKE3QCO4Fnv4u8d/iQdHd2ADsrEhIAKJQ6/EQ=; b=IKXLCaiNbpIAHk+czHTczG07ijOghtF6KzM9Wph62NIFtuNRZTJ+GAN34op93V/fX4 AEDpMPRXolGU1FI7FLp/crNWjHsmImMNnm1/BtPjdm1N5nsj0DfK5m5kRkGXK0lTjd28 dYOJ2Gf045TiKp+uhYXo7Re0OWVwTWZZJmvxVAzbd1kCyvWrDdxIrfpJ0htIGvC93Nsi 0sicojpMpA8JVflfuJIWU2T3CWqAmDoNlcRcKuNTIOADfgSoGBQklfA5UfeWlMcVqNth 9u7cx/r3zmddt86/leHf0uFzbLIxs74tIyWyGFQxWIJEWUmG5AmC6ng8uplJcVai00yu 5svg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tX6SQ83K; 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 k2-v6si20956378plt.374.2018.05.24.03.53.59; Thu, 24 May 2018 03:54:13 -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=tX6SQ83K; 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 S1032641AbeEXKxQ (ORCPT + 99 others); Thu, 24 May 2018 06:53:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:37026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030366AbeEXJ5L (ORCPT ); Thu, 24 May 2018 05:57:11 -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 EBC9720891; Thu, 24 May 2018 09:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155830; bh=VQayhQgcCz8LRkunYtDT2u2fMChtTObT4NlKNK2NnVo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tX6SQ83KeFlAGFxU0S8PTsAeZaVozhG/A26/YzT29jo/3R+mCC+Hi1j5rrJVNkqS0 Ff/CROgerlDklOzfsj4HSEypZhJtTri6NnAPLUgcCvBfiy+5ipEv2NpPDnpsM2OFKR 0KjO8bjSFpU70tTpLQFIogtfZh8KqYhIpUk1vIUM= 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.14 115/165] scsi: aacraid: Insure command thread is not recursively stopped Date: Thu, 24 May 2018 11:38:41 +0200 Message-Id: <20180524093626.674772111@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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 @@ -1530,9 +1530,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; } @@ -1619,6 +1620,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 @@ -1565,6 +1565,7 @@ static void __aac_shutdown(struct aac_de up(&fib->event_wait); } kthread_stop(aac->thread); + aac->thread = NULL; } aac_send_shutdown(aac);