Received: by 10.223.176.5 with SMTP id f5csp1060301wra; Fri, 2 Feb 2018 10:29:16 -0800 (PST) X-Google-Smtp-Source: AH8x224Jnij1e3BOXnt4LOMageTUf8r+lAEP59LAn2ooqFACi/lfKq/ek9SQwmL9TxVjURzOhdKl X-Received: by 2002:a17:902:4683:: with SMTP id p3-v6mr27389119pld.408.1517596156302; Fri, 02 Feb 2018 10:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517596156; cv=none; d=google.com; s=arc-20160816; b=LWSnRdQdSgkGUP/E+/Hj8vYJtSbF1Mnit5SNRM8JJuMrLymWT52DOXSyqNaI+5B6eA FXshMXKEoov+hnRAGlEvlpKrypIUC+udzINgjcw39UOOVrx40yiaFSOjMSkvle19iRFb k+zVmouKmpOEhZ7xBdmjGaRov7dvuYb1ZWBa2SXI/bI//4LX4IM1vFx8ioh3L3Y6eONU 3lrd8PalBLeLM4sBdQC6X7KqhhlBS+xLth6YG5Ld56EcDyLOFEPL0rlSWk9KB/sY1HyD AWPZuIMO1i1WEPVhFvlOEQg4I0i1Q4Sl7H6ZpnP8MJlV6MXdo6JgaqY4rNLvz2LnP7ls /rwA== 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 :arc-authentication-results; bh=fRIbjXh9vVQViak/bF2/qIDOwTr+sMxx0vD6ej7Y7ko=; b=LOAT4jyyD/Hk1ObWdZgJr1nmJtfHXDH7dGLZEzR0WzVhfth6MxKLSLEKiv3a20F3YH 152FspGFTmF2ru+FpQYlEQn34f3SA1YmnJrXPRZK8sI9lBU2ClIuN1jZgAUiEGb8wFnT ikxg7Ca3yj8Pm7xZjpAu/qbo1Ty2iBX2E0hmRf7A9wlM6cJjo9JPLLQvD3iWu1zX93MZ NwWC//URpBWq3+Xqz8kSLSSaOJe3sx6t+AgMztIbSebFJB/3JI13t8XNzpZ7sYEvFRdJ 1kzGinM9Y/76wHb2teN1OB3ddK7O1Ef/IrKlmqp5L17nbRFd8mqlrakMLIKC/TVVBRq4 nQ2g== ARC-Authentication-Results: i=1; mx.google.com; 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 d21-v6si2187130pll.268.2018.02.02.10.29.01; Fri, 02 Feb 2018 10:29:16 -0800 (PST) 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; 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 S1754502AbeBBS2D (ORCPT + 99 others); Fri, 2 Feb 2018 13:28:03 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35166 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbeBBRBf (ORCPT ); Fri, 2 Feb 2018 12:01:35 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BF20ADFF; Fri, 2 Feb 2018 17:01:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Guilherme G. Piccoli" , Raghava Aditya Renukunta , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.4 50/67] scsi: aacraid: Prevent crash in case of free interrupt during scsi EH path Date: Fri, 2 Feb 2018 17:58:19 +0100 Message-Id: <20180202140820.869816404@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140815.091718203@linuxfoundation.org> References: <20180202140815.091718203@linuxfoundation.org> User-Agent: quilt/0.65 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Guilherme G. Piccoli" [ Upstream commit e4717292ddebcfe231651b5aff9fa19ca158d178 ] As part of the scsi EH path, aacraid performs a reinitialization of the adapter, which encompass freeing resources and IRQs, NULLifying lots of pointers, and then initialize it all over again. We've identified a problem during the free IRQ portion of this path if CONFIG_DEBUG_SHIRQ is enabled on kernel config file. Happens that, in case this flag was set, right after free_irq() effectively clears the interrupt, it checks if it was requested as IRQF_SHARED. In positive case, it performs another call to the IRQ handler on driver. Problem is: since aacraid currently free some resources *before* freeing the IRQ, once free_irq() path calls the handler again (due to CONFIG_DEBUG_SHIRQ), aacraid crashes due to NULL pointer dereference with the following trace: aac_src_intr_message+0xf8/0x740 [aacraid] __free_irq+0x33c/0x4a0 free_irq+0x78/0xb0 aac_free_irq+0x13c/0x150 [aacraid] aac_reset_adapter+0x2e8/0x970 [aacraid] aac_eh_reset+0x3a8/0x5d0 [aacraid] scsi_try_host_reset+0x74/0x180 scsi_eh_ready_devs+0xc70/0x1510 scsi_error_handler+0x624/0xa20 This patch prevents the crash by changing the order of the deinitialization in this path of aacraid: first we clear the IRQ, then we free other resources. No functional change intended. Signed-off-by: Guilherme G. Piccoli 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1363,13 +1363,13 @@ static int _aac_reset_adapter(struct aac * will ensure that i/o is queisced and the card is flushed in that * case. */ + aac_free_irq(aac); aac_fib_map_free(aac); pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys); aac->comm_addr = NULL; aac->comm_phys = 0; kfree(aac->queues); aac->queues = NULL; - aac_free_irq(aac); kfree(aac->fsa_dev); aac->fsa_dev = NULL; quirks = aac_get_driver_ident(index)->quirks;