linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] scsi: fnic: fix use after free
@ 2019-11-04 15:26 Pan Bian
  2019-11-05  5:22 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-11-04 15:26 UTC (permalink / raw)
  To: Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
	James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel, Pan Bian

The memory chunk io_req is released by mempool_free. Accessing
io_req->start_time will result in a use after free bug. Thevariable
start_time is a backup of the timestamp. So, use start_time here to
avoid use after free.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 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 80608b53897b..d3986a25d9c2 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -1024,7 +1024,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.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] scsi: fnic: fix use after free
  2019-11-04 15:26 [PATCH 1/1] scsi: fnic: fix use after free Pan Bian
@ 2019-11-05  5:22 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2019-11-05  5:22 UTC (permalink / raw)
  To: Pan Bian
  Cc: Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel


Pan,

> 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.

Applied to 5.5/scsi-queue, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-05  5:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 15:26 [PATCH 1/1] scsi: fnic: fix use after free Pan Bian
2019-11-05  5:22 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).