scsi: target: core: Fix warning on RT kernels
Subsystems (6)
Sasha Levin
maintainerPATCH 1/3 scsi: target: core: Fix warning on RT kernels
From: Maurizio Lombardi <[email protected]>
[ Upstream commit 84ed64b1a7a7fcd507598dee7708c1f225123711 ]
Calling spin_lock_irqsave() does not disable the interrupts on realtime kernels, remove the warning and replace assert_spin_locked() with lockdep_assert_held().
--- drivers/target/target_core_tmr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/target/target_core_tmr.c +2 -2
@@ -114,8 +114,8 @@ static bool __target_check_io_state(struct se_cmd *se_cmd, {struct se_session *sess = se_cmd->se_sess; -assert_spin_locked (&sess->sess_cmd_lock); -WARN_ON_ONCE (!irqs_disabled ()); +lockdep_assert_held (&sess->sess_cmd_lock); +/* * If command already reached CMD_T_COMPLETE state within * target_complete_cmd() or CMD_T_FABRIC_STOP due to shutdown,
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 2/3 scsi: iscsi_tcp: Fix UAF during login when accessing the shost ipaddress
From: Mike Christie <[email protected]>
[ Upstream commit f484a794e4ee2a9ce61f52a78e810ac45f3fe3b3 ]
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.
--- drivers/scsi/iscsi_tcp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/iscsi_tcp.c +6 -3
@@ -773,7 +773,7 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param, char *buf) { struct iscsi_sw_tcp_host *tcp_sw_host = iscsi_host_priv(shost); -struct iscsi_session *session = tcp_sw_host->session; +struct iscsi_session *session;struct iscsi_conn *conn;struct iscsi_tcp_conn *tcp_conn;struct iscsi_sw_tcp_conn *tcp_sw_conn;
@@ -782,6 +782,7 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,switch (param) {case ISCSI_HOST_PARAM_IPADDRESS : + session = tcp_sw_host->session;if (!session)return -ENOTCONN ;
@@ -870,12 +871,14 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max,if (!cls_session) goto remove_host; session = cls_session->dd_data; - tcp_sw_host =iscsi_host_priv (shost); - tcp_sw_host->session = session; shost->can_queue = session->scsi_cmds_max;if (iscsi_tcp_r2tpool_alloc (session)) goto remove_session; + +/* We are now fully setup so expose the session to sysfs. */ + tcp_sw_host =iscsi_host_priv (shost); + tcp_sw_host->session = session;return cls_session; remove_session:
Signature · 1 line
2.39.0
Sasha Levin
maintainerPATCH 3/3 net/x25: Fix to not accept on connected socket
In reply to Sasha LevinFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit f2b0b5210f67c56a3bcdf92ff665fb285d6e0067 ]
When listen() and accept() are called on an x25 socket that connect() succeeds, accept() succeeds immediately. This is because x25_connect() queues the skb to sk->sk_receive_queue, and x25_accept() dequeues it.
This creates a child socket with the sk of the parent x25 socket, which can cause confusion.
Fix x25_listen() to return -EINVAL if the socket has already been successfully connect()ed to avoid this issue.
--- net/x25/af_x25.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/x25/af_x25.c +6 -0
@@ -496,6 +496,12 @@ static int x25_listen(struct socket *sock, int backlog)int rc = -EOPNOTSUPP ;lock_sock (sk); +if (sock->state !=SS_UNCONNECTED ) { + rc = -EINVAL ; +release_sock (sk); +return rc; + } +if (sk->sk_state !=TCP_LISTEN ) {memset (&x25_sk (sk)->dest_addr,0 ,X25_ADDR_LEN ); sk->sk_max_ack_backlog = backlog;
Signature · 1 line
2.39.0