[RHEL7,COMMIT] ms/target: Drop signal_pending checks after interruptible lock acquire

Submitted by Konstantin Khorenko on April 27, 2018, 8:59 a.m.

Details

Message ID 201804270859.w3R8xJPp031027@finist_ce7.work
State New
Series "target: Drop signal_pending checks after interruptible lock acquire"
Headers show

Commit Message

Konstantin Khorenko April 27, 2018, 8:59 a.m.
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.47.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.46.7
------>
commit 3f89460cf819aaed316e83eb4c2df8c6f44178df
Author: Nicholas Bellinger <nab@linux-iscsi.org>
Date:   Fri Apr 27 11:59:19 2018 +0300

    ms/target: Drop signal_pending checks after interruptible lock acquire
    
    ML: ee7619f2eb21304dcc846b8dc8f8c3d6cbe11792
    
    Once upon a time, iscsit_get_tpg() was using an un-interruptible
    lock.  The signal_pending() usage was a check to allow userspace
    to break out of the operation with SIGINT.
    
    AFAICT, there's no reason why this is necessary anymore, and as
    reported by Alexey can be potentially dangerous.  Also, go ahead
    and drop the other two problematic cases within iscsit_access_np()
    and sbc_compare_and_write() as well.
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    https://pmc.acronis.com/browse/VSTOR-9577
    
    Reported-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
 drivers/target/iscsi/iscsi_target.c     | 2 +-
 drivers/target/iscsi/iscsi_target_tpg.c | 5 +----
 drivers/target/target_core_sbc.c        | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 2ec68f26e4d5..45fda61f3637 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -232,7 +232,7 @@  int iscsit_access_np(struct iscsi_np *np, struct iscsi_portal_group *tpg)
 	 * Here we serialize access across the TIQN+TPG Tuple.
 	 */
 	ret = down_interruptible(&tpg->np_login_sem);
-	if ((ret != 0) || signal_pending(current))
+	if (ret != 0)
 		return -1;
 
 	spin_lock_bh(&tpg->tpg_state_lock);
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index 792d3eecc16f..896681697942 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -164,10 +164,7 @@  struct iscsi_portal_group *iscsit_get_tpg_from_np(
 int iscsit_get_tpg(
 	struct iscsi_portal_group *tpg)
 {
-	int ret;
-
-	ret = mutex_lock_interruptible(&tpg->tpg_access_lock);
-	return ((ret != 0) || signal_pending(current)) ? -1 : 0;
+	return mutex_lock_interruptible(&tpg->tpg_access_lock);
 }
 
 void iscsit_put_tpg(struct iscsi_portal_group *tpg)
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 5578e4d21226..f7f55851ee3d 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -567,7 +567,7 @@  sbc_compare_and_write(struct se_cmd *cmd)
 	 * comparision using SGLs at cmd->t_bidi_data_sg..
 	 */
 	rc = down_interruptible(&dev->caw_sem);
-	if ((rc != 0) || signal_pending(current)) {
+	if (rc != 0) {
 		cmd->transport_complete_callback = NULL;
 		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 	}