Received: by 10.223.176.5 with SMTP id f5csp992825wra; Fri, 2 Feb 2018 09:22:34 -0800 (PST) X-Google-Smtp-Source: AH8x2261v5rvTnmkp46Kvm0WTMPx7g26HNr7WEiLBiqW2Y5iBHSMj+fTvipaKp2EOsLEkBVqSWJl X-Received: by 10.101.78.201 with SMTP id w9mr30820409pgq.43.1517592153960; Fri, 02 Feb 2018 09:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592153; cv=none; d=google.com; s=arc-20160816; b=ODZKofnDW5DUso/c5tknOiJDLm+sru3Wp7eNJTnj9+0dPhw8odhfvStqZr3WDF5mXC 5nrzitzwJIBS5ukxWHZyJtNMJkXtxNMLhf2sFXltNgm48tdM++zNogAcgMXd10K9uGJV 9Apg5kpeilJQogpx8p4IbrpOGunCzDWMNgvPDmT0RHLddlnjJQRUyl/H18mIQVPSDO3y R32Ey8DTYzkLzvuM+b/uBPHjdTYt5Vp1uSDZHXttX5Vxavkwgeqdg0E2KSUAr6fbjbN9 fIJ56zgaLYGH3oqghrEthoKSC59wEPR7IBkDYl0RZZQnGtXF/WV2an0zuhiymo1ecJ3F 7R8A== 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=PHzkQX7pwHRpD4uTBq2uwOsgQakG/vCChretdpV8+r4=; b=T7034cmUg3PeF8Ct7YBHudmY7AUBhSck8GS0Fga8HrFw2qthRb/Ml3CfxfnOXgOZWp ytK6EcrsWzrfxsdcoRTDd10qYoQUvN4+iJlhOqN9Cz3v5RwZK8L1l+Q+nOifLMQAyues H+4UxE/+EKuxYjUVZzxN6AqIxefkDnKFVNW8Nqekk4DbYhZh1tlKAb0Wh6yzIsvvSK6e tG+FWMuOJoR5hK0xVpz+GlDZCO6Dq6j9Cd8hagAkUOV2uhsf9AExhs4o6W32hHiA390g ZAKqaPhUn8GgsUSYEMnaAflS3bL3f91bZB/GEDbRsPvd2LScAl8ePf27GBfMv69CJ1e5 SYcA== 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 r74si2110560pfg.270.2018.02.02.09.22.18; Fri, 02 Feb 2018 09:22:33 -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 S1753932AbeBBRUK (ORCPT + 99 others); Fri, 2 Feb 2018 12:20:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38996 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753467AbeBBRM0 (ORCPT ); Fri, 2 Feb 2018 12:12:26 -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 88681F21; Fri, 2 Feb 2018 17:12:24 +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.14 117/156] scsi: aacraid: Prevent crash in case of free interrupt during scsi EH path Date: Fri, 2 Feb 2018 17:58:18 +0100 Message-Id: <20180202140845.475716367@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@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.14-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 @@ -1583,6 +1583,7 @@ 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); dma_free_coherent(&aac->pdev->dev, aac->comm_size, aac->comm_addr, aac->comm_phys); @@ -1590,7 +1591,6 @@ static int _aac_reset_adapter(struct aac aac->comm_phys = 0; kfree(aac->queues); aac->queues = NULL; - aac_free_irq(aac); kfree(aac->fsa_dev); aac->fsa_dev = NULL;