[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230915171111.4057930-1-edumazet@google.com>
Date: Fri, 15 Sep 2023 17:11:11 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: Lee Duncan <lduncan@...e.com>,
Mike Christie <michael.christie@...cle.com>,
Chris Leech <cleech@...hat.com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
netdev@...r.kernel.org, Eric Dumazet <edumazet@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
open-iscsi@...glegroups.com, linux-scsi@...r.kernel.org
Subject: [PATCH] scsi: iscsi_tcp: restrict to TCP sockets
Nothing prevents iscsi_sw_tcp_conn_bind() to receive file descriptor
pointing to non TCP socket (af_unix for example).
Return -EINVAL if this is attempted, instead of crashing the kernel.
Fixes: 7ba247138907 ("[SCSI] open-iscsi/linux-iscsi-5 Initiator: Initiator code")
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Cc: Lee Duncan <lduncan@...e.com>
Cc: Chris Leech <cleech@...hat.com>
Cc: Mike Christie <michael.christie@...cle.com>
Cc: "James E.J. Bottomley" <jejb@...ux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@...cle.com>
Cc: open-iscsi@...glegroups.com
Cc: linux-scsi@...r.kernel.org
---
drivers/scsi/iscsi_tcp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 9ab8555180a3a0bd159b621a57c99bcb8f0413ae..8e14cea15f980829e99afa2c43bf6872fcfd965c 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -724,6 +724,10 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
return -EEXIST;
}
+ err = -EINVAL;
+ if (!sk_is_tcp(sock->sk))
+ goto free_socket;
+
err = iscsi_conn_bind(cls_session, cls_conn, is_leading);
if (err)
goto free_socket;
--
2.42.0.459.ge4e396fd5e-goog
Powered by blists - more mailing lists