Skip to contentSkip to conversation

scsi: iscsi_tcp: restrict to TCP sockets

PATCH Applied Eric Dumazet 3 participants 3 messages Sep 15, 2023 – Sep 17, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
Cc Lee Duncan <[email protected]>
Cc Chris Leech <[email protected]>
Cc Mike Christie <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
---
 drivers/scsi/iscsi_tcp.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/iscsi_tcp.c +4 -0
index 9ab8555180a3a0bd159b621a57c99bcb8f0413ae..8e14cea15f980829e99afa2c43bf6872fcfd965c 100644
@@ -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;
Signature · 1 line
2.42.0.459.ge4e396fd5e-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Eric Dumazet

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.

#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 15 lines · On Fri, 15 Sep 2023 17:11:11 +0000 you wrote:

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")
Cc Lee Duncan <[email protected]>
Cc Chris Leech <[email protected]>
Cc Mike Christie <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Quoted 1 line

[...]

Here is the summary with links:
- scsi: iscsi_tcp: restrict to TCP sockets

    https://git.kernel.org/netdev/net/c/f4f82c52a0ea

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html