From patchwork Tue Sep 29 10:55:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ECE9C47425 for ; Tue, 29 Sep 2020 12:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEB14207C4 for ; Tue, 29 Sep 2020 12:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601381741; bh=9sPnZcdcywX+RFFkXZmOcVM+kDvPcBHZNc1GSan6ogQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TiOAREVmur9kPSF5lJaTl6EcvOdHErAQDuU6lNcpke3KuUHCeYeO0PuxrZnNwNAHA HWmToPhXwzzS0tdfuUT78W1uVYF7WkjT82JtqeW5BbrxZK9ZcKXhhyJyWI4ZDbxdJs JCJ0J+V9Vj1yLcR1KkhD/X5sM1T4/6bntyGugORU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730222AbgI2MPO (ORCPT ); Tue, 29 Sep 2020 08:15:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730102AbgI2Lh2 (ORCPT ); Tue, 29 Sep 2020 07:37:28 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 D222623B09; Tue, 29 Sep 2020 11:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379199; bh=9sPnZcdcywX+RFFkXZmOcVM+kDvPcBHZNc1GSan6ogQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7SS0teP/G4v1/dEV11u/YvCf3CgrNFPFXUbJeNgyAqTIc8zUGfQQaWVroUfX1PPU 1anD/Hg8B1CDVyrG8/EkQXn9nTO9rdhdhkNm+xSrCh0TsEXCcP6uKZ1rhotr2le2vD rZonJ+3+xOfyT3C/zPIuvoSrNt9j/gGla8CgyQwk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Satish Kharat , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 026/388] scsi: fnic: fix use after free Date: Tue, 29 Sep 2020 12:55:57 +0200 Message-Id: <20200929110011.753051657@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pan Bian [ Upstream commit ec990306f77fd4c58c3b27cc3b3c53032d6e6670 ] The memory chunk io_req is released by mempool_free. Accessing io_req->start_time will result in a use after free bug. The variable start_time is a backup of the timestamp. So, use start_time here to avoid use after free. Link: https://lore.kernel.org/r/1572881182-37664-1-git-send-email-bianpan2016@163.com Signed-off-by: Pan Bian Reviewed-by: Satish Kharat Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/fnic/fnic_scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index e3f5c91d5e4fe..b60795893994c 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -1027,7 +1027,8 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, atomic64_inc(&fnic_stats->io_stats.io_completions); - io_duration_time = jiffies_to_msecs(jiffies) - jiffies_to_msecs(io_req->start_time); + io_duration_time = jiffies_to_msecs(jiffies) - + jiffies_to_msecs(start_time); if(io_duration_time <= 10) atomic64_inc(&fnic_stats->io_stats.io_btw_0_to_10_msec);