lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210524095039.9033-1-lyl2019@mail.ustc.edu.cn>
Date:   Mon, 24 May 2021 02:50:39 -0700
From:   Lv Yunlong <lyl2019@...l.ustc.edu.cn>
To:     subbu.seetharaman@...adcom.com, ketan.mukadam@...adcom.com,
        jitendra.bhivare@...adcom.com, jejb@...ux.ibm.com,
        martin.petersen@...cle.com
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Lv Yunlong <lyl2019@...l.ustc.edu.cn>
Subject: [PATCH] scsi: be2iscsi: Fix a use after free in beiscsi_if_clr_ip

In the free_cmd error path of callee beiscsi_exec_nemb_cmd(),
nonemb_cmd->va is freed by dma_free_coherent().
As req = nonemb_cmd.va, we can see that the freed nonemb_cmd.va
is still dereferenced and used by req->ip_params.ip_record.status.

My patch uses status to replace req->ip_params.ip_record.status
to avoid the uaf.

Signed-off-by: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
---
 drivers/scsi/be2iscsi/be_mgmt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 462717bbb5b7..f05fcea707cd 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -509,6 +509,7 @@ beiscsi_if_clr_ip(struct beiscsi_hba *phba,
 {
 	struct be_cmd_set_ip_addr_req *req;
 	struct be_dma_mem nonemb_cmd;
+	u32 status;
 	int rc;
 
 	rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
@@ -531,11 +532,12 @@ beiscsi_if_clr_ip(struct beiscsi_hba *phba,
 	memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
 	       if_info->ip_addr.subnet_mask,
 	       sizeof(if_info->ip_addr.subnet_mask));
+	status = req->ip_params.ip_record.status;
 	rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0);
-	if (rc < 0 || req->ip_params.ip_record.status) {
+	if (rc < 0 || status) {
 		beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
 			    "BG_%d : failed to clear IP: rc %d status %d\n",
-			    rc, req->ip_params.ip_record.status);
+			    rc, status);
 	}
 	return rc;
 }
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ