svn commit: r360610 - head/sys/cam/ctl

Alexander Motin mav at FreeBSD.org
Sun May 3 16:14:56 UTC 2020


Author: mav
Date: Sun May  3 16:14:55 2020
New Revision: 360610
URL: https://svnweb.freebsd.org/changeset/base/360610

Log:
  Add session locking in cfiscsi_ioctl_handoff().
  
  While there, remove ifdef around cs_target check in cfiscsi_ioctl_list().
  I am not sure why this ifdef was added, but without this check code will
  crash below on NULL dereference.
  
  Submitted by:	Aleksandr Fedorov <aleksandr.fedorov at itglobal.com>
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D24587

Modified:
  head/sys/cam/ctl/ctl_frontend_iscsi.c

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.c	Sun May  3 16:09:35 2020	(r360609)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c	Sun May  3 16:14:55 2020	(r360610)
@@ -1582,8 +1582,10 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
 	mtx_lock(&softc->lock);
 	if (ct->ct_online == 0) {
 		mtx_unlock(&softc->lock);
+		CFISCSI_SESSION_LOCK(cs);
 		cs->cs_handoff_in_progress = false;
 		cfiscsi_session_terminate(cs);
+		CFISCSI_SESSION_UNLOCK(cs);
 		cfiscsi_target_release(ct);
 		ci->status = CTL_ISCSI_ERROR;
 		snprintf(ci->error_str, sizeof(ci->error_str),
@@ -1629,8 +1631,10 @@ restart:
 #endif
 		error = icl_conn_handoff(cs->cs_conn, cihp->socket);
 		if (error != 0) {
+			CFISCSI_SESSION_LOCK(cs);
 			cs->cs_handoff_in_progress = false;
 			cfiscsi_session_terminate(cs);
+			CFISCSI_SESSION_UNLOCK(cs);
 			ci->status = CTL_ISCSI_ERROR;
 			snprintf(ci->error_str, sizeof(ci->error_str),
 			    "%s: icl_conn_handoff failed with error %d",
@@ -1692,10 +1696,8 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
 	sbuf_printf(sb, "<ctlislist>\n");
 	mtx_lock(&softc->lock);
 	TAILQ_FOREACH(cs, &softc->sessions, cs_next) {
-#ifdef ICL_KERNEL_PROXY
 		if (cs->cs_target == NULL)
 			continue;
-#endif
 		error = sbuf_printf(sb, "<connection id=\"%d\">"
 		    "<initiator>%s</initiator>"
 		    "<initiator_addr>%s</initiator_addr>"


More information about the svn-src-head mailing list