2023-09-16 02:35:03

by Eric Dumazet

[permalink] [raw]
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 <[email protected]>
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]>
Cc: [email protected]
Cc: [email protected]
---
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


2023-09-16 05:05:57

by Mike Christie

[permalink] [raw]
Subject: Re: [PATCH] scsi: iscsi_tcp: restrict to TCP sockets

On 9/15/23 12:11 PM, Eric Dumazet 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.
>

Reviewed-by: Mike Christie <[email protected]>

2023-09-17 16:52:46

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] scsi: iscsi_tcp: restrict to TCP sockets

Hello:

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

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")
> Signed-off-by: Eric Dumazet <[email protected]>
> 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]>
> Cc: [email protected]
> Cc: [email protected]
>
> [...]

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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html