Skip to content

Commit e7722d4

Browse files
committed
scsi: iscsi_tcp: Fix UAF during login when accessing the shost ipaddress
jira VULN-55147 cve CVE-2023-52974 commit-author Mike Christie <michael.christie@oracle.com> commit f484a79 If during iscsi_sw_tcp_session_create() iscsi_tcp_r2tpool_alloc() fails, userspace could be accessing the host's ipaddress attr. If we then free the session via iscsi_session_teardown() while userspace is still accessing the session we will hit a use after free bug. Set the tcp_sw_host->session after we have completed session creation and can no longer fail. Link: https://lore.kernel.org/r/20230117193937.21244-3-michael.christie@oracle.com Signed-off-by: Mike Christie <michael.christie@oracle.com> Reviewed-by: Lee Duncan <lduncan@suse.com> Acked-by: Ding Hui <dinghui@sangfor.com.cn> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit f484a79) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent d8f82a0 commit e7722d4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/scsi/iscsi_tcp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,
791791
enum iscsi_host_param param, char *buf)
792792
{
793793
struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(shost);
794-
struct iscsi_session *session = tcp_sw_host->session;
794+
struct iscsi_session *session;
795795
struct iscsi_conn *conn;
796796
struct iscsi_tcp_conn *tcp_conn;
797797
struct iscsi_sw_tcp_conn *tcp_sw_conn;
@@ -801,6 +801,7 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,
801801

802802
switch (param) {
803803
case ISCSI_HOST_PARAM_IPADDRESS:
804+
session = tcp_sw_host->session;
804805
if (!session)
805806
return -ENOTCONN;
806807

@@ -897,11 +898,13 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,
897898
if (!cls_session)
898899
goto remove_host;
899900
session = cls_session->dd_data;
900-
tcp_sw_host = iscsi_host_priv(shost);
901-
tcp_sw_host->session = session;
902901

903902
if (iscsi_tcp_r2tpool_alloc(session))
904903
goto remove_session;
904+
905+
/* We are now fully setup so expose the session to sysfs. */
906+
tcp_sw_host = iscsi_host_priv(shost);
907+
tcp_sw_host->session = session;
905908
return cls_session;
906909

907910
remove_session:

0 commit comments

Comments
 (0)