Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp882855pxk; Thu, 17 Sep 2020 20:15:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaeB4bD7heXifyD1zjE4JKDrCKeiNWmX4gTXic7OF3UY9MjjNVbpplrgsysv19ETkUaY9N X-Received: by 2002:a50:f1cd:: with SMTP id y13mr29491643edl.358.1600398935466; Thu, 17 Sep 2020 20:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398935; cv=none; d=google.com; s=arc-20160816; b=jIKZN8PEsEmwvj8d+ErvFnFmrQwCoOcOy/aseHmSJKNlF9zY2c598a4AyePT8829mF Wt50OaNIaek7k4k6QRWCoTDxrS1K/fgix9BPWX3jtxDE9M+MbQTOCZrDa8Ds+R1aX94S Y/7A6iRhm4/x410cw9cBjea+7jjL/p3M/XL343uM9fjk8QWn5MxUiOQm3Bw5KoOiG8JZ E8rVCts7BcIom4/1BTLbnjiM1r+agWuew0Io0SWo4mwjtxO7WIFhqjJZXifJc/GVS0uD w4ukCwuRDhm26GuLvH5NSoa88ZOm5sC8IKOLI9/ogpH571PudM6UPmBmgQ4sBISE+/r6 kA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fs6rEi2AMpzJQXMF8+VBfZCoyZD3iv3c6NUSbuBlDTY=; b=ZShA0z6EM6OReuQOVHab+AZRsO9AH01BLE5LGJJqG0a2NupiKqMgeFtxQZaHWgLGir qIj+I8MMT6Tupn1GTUTEwqcDwI8hy7obMZe+rLSI3Ud1uh8E4gEJZZaW/kAGZDaQB0IJ WJyhcKu41BNxDwZfVmKTtiWccpyzo829IG/1SvVieUlnI4KvMBHPZ+QrblSpL1CZroam lktDxftbg+5J6f6NXcpJyr2MKn2QtMYvjaM8HjwmGqhc6Ae/Qi3lgTV42JOY1laAABbR gGzBxX9io4rs3P+s9kEhTIIt0lyphVFOGnVtL94CR0OZxjpRdVzgZVfxUPRmLZ/GYi6Y 3Vag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=12sPDjrm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si1178781ejd.657.2020.09.17.20.15.11; Thu, 17 Sep 2020 20:15:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=12sPDjrm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730737AbgIRDOV (ORCPT + 99 others); Thu, 17 Sep 2020 23:14:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:45806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbgIRCBp (ORCPT ); Thu, 17 Sep 2020 22:01:45 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F341E2087D; Fri, 18 Sep 2020 02:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394504; bh=9sPnZcdcywX+RFFkXZmOcVM+kDvPcBHZNc1GSan6ogQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=12sPDjrmGRrpDjPs1BIgmCq42HBxJ3UhPDh2YJWmDUT8waSNASFgdTkqlqdafJ5g9 9qSi2X+Ojvu9aXifW9EUT4n/vc75oDsC3gYNNdeT96JtleBy0AXt6SicnM9xFM+34X FBvIiFA1xFZnhpGJEQaWlDFiFoz82LxdgctewRlg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pan Bian , Satish Kharat , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 028/330] scsi: fnic: fix use after free Date: Thu, 17 Sep 2020 21:56:08 -0400 Message-Id: <20200918020110.2063155-28-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.25.1