Commit 1897a9e8 authored by Jianglei Nie's avatar Jianglei Nie Committed by Baokun Li
Browse files

scsi: libfc: Fix use after free in fc_exch_abts_resp()

stable inclusion
from stable-v4.19.238
commit 6044ad64f41c87382cfeeca281573d1886d80cbe
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBPBYM
CVE: CVE-2022-49114

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6044ad64f41c87382cfeeca281573d1886d80cbe

--------------------------------

[ Upstream commit 271add11 ]

fc_exch_release(ep) will decrease the ep's reference count. When the
reference count reaches zero, it is freed. But ep is still used in the
following code, which will lead to a use after free.

Return after the fc_exch_release() call to avoid use after free.

Link: https://lore.kernel.org/r/20220303015115.459778-1-niejianglei2021@163.com


Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJianglei Nie <niejianglei2021@163.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
parent df354167
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1703,6 +1703,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
	if (cancel_delayed_work_sync(&ep->timeout_work)) {
		FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n");
		fc_exch_release(ep);	/* release from pending timer hold */
		return;
	}

	spin_lock_bh(&ep->ex_lock);