Received: by 10.223.176.5 with SMTP id f5csp1030180wra; Fri, 2 Feb 2018 10:00:23 -0800 (PST) X-Google-Smtp-Source: AH8x227YGNtxQ7cFPSllcVoj42Uj/3S7dcRcUOlk3CfPqdyWX5XCG5I0SktCvv2c0TNrk9QlkY1V X-Received: by 2002:a17:902:4464:: with SMTP id k91-v6mr7951688pld.267.1517594423459; Fri, 02 Feb 2018 10:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594423; cv=none; d=google.com; s=arc-20160816; b=h7Ai9hACjC8cMe4w5TdfwhPdMHebMSZafWDEpAeEjX1Slpe0GK/cqbFDzMXnUgGbfS YMpmVig8+6rHUjjq3jLe0NmaGO1G19rlamzfXz741MYDTrbOk+grpSCTt33As5pLGf4V dK1vvst76mg9jWDKqo+8NieE9QgEGVrc7Rx8b9DGVlotIek5b+4cUarpIDWEHY0Av/tC N+9MREtKGgZOXxRL6zYrlQ7XOpJtihEKRdHqp7azn/TdBAAS8gF3grQDkJlHIijH6U/L 1qHzgni+kcdZp9vgMkznVGMzoA9aRpZHGtisuW7WUUfFsWHd9dnIOm8Gs026TxzCQSPy ON7w== 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=hxqnZuCTBL5G3tKo7ZAJf/NfPTao8wUcXY4gH+0ODqM=; b=qyni5QUtyd/u87ux0zXtDHsvfQTYOQOdF+mnvmXwS0XSdilAjcEdEA2IzEsqXJ3wr0 p3ceCyfGgc/WqyBZNqX3kYcyPuBEwo6K9ST7oOyMBQ+cHoq+VPCJxcQnPtt5Q+sWfJza N7QmaXjaBoeFM835y5vOqIHA1cmK60+A9U014y+089mrX/K9IXt0gS2T7uUsMNeJ/G7s YP2cWzKltIAg8tJAFdZvMoRqmAizOtnQoXbRwf8s5cPWVv/IFiokQIGeL1qD5Y6lXW/7 IS3o6JpEiKzZ1uJE8/RLD3Ebt9WZvkWP1NzhMjinpO0xpAQJKPHGGhhuPcuW+A2YrG1Q Q3BQ== 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 p9-v6si277077pls.317.2018.02.02.10.00.08; Fri, 02 Feb 2018 10:00:23 -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 S1753289AbeBBRK2 (ORCPT + 99 others); Fri, 2 Feb 2018 12:10:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36506 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755AbeBBRFa (ORCPT ); Fri, 2 Feb 2018 12:05:30 -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 3CA7DE16; Fri, 2 Feb 2018 17:05:30 +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.9 63/86] scsi: aacraid: Prevent crash in case of free interrupt during scsi EH path Date: Fri, 2 Feb 2018 17:58:23 +0100 Message-Id: <20180202140828.405707791@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140822.679101338@linuxfoundation.org> References: <20180202140822.679101338@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.9-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 @@ -1416,13 +1416,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;