diff options
author | Eric Dumazet <[email protected]> | 2023-09-15 17:11:11 +0000 |
---|---|---|
committer | David S. Miller <[email protected]> | 2023-09-17 17:46:13 +0100 |
commit | f4f82c52a0ead5ab363d207d06f81b967d09ffb8 (patch) | |
tree | 00d6c089b6dab76ba5e55f71f5b63e61efd34505 | |
parent | 0113d9c9d1ccc07f5a3710dac4aa24b6d711278c (diff) |
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]
Reviewed-by: Mike Christie <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 9ab8555180a3..8e14cea15f98 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; |