[Devel] [PATCH RHEL7 COMMIT] ploop: push_backup: fix reentrance in ploop_pb_get_pending()

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 10 09:22:50 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.17
------>
commit 7cd35b576e4e45248df9ad7728f207fd1fc5a462
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date:   Tue May 10 20:22:50 2016 +0400

    ploop: push_backup: fix reentrance in ploop_pb_get_pending()
    
    The patch implements what Dima Monakhov suggested:
    
    >  AFAIU you have a re-entrance issue if several tasks want performs ioctls
    >   task1:ioctl->wait
    > 		    task2:ioctl->wait
    >
    >   Just change wait sequence like this and you are safe:
    > 		   /* blocking case */
    > 		  if (unlikely(pbd->ppb_waiting))
    > 		       /* Other task is already waitng for event */
    > 		       err = -EBUSY;
    > 		       goto get_pending_unlock;
    > 		  }
    > 		  pbd->ppb_waiting = true;
    > 		  spin_unlock(&pbd->ppb_lock);
    > 		  mutex_unlock(&plo->ctl_mutex);
    
    Fixes commit adcff732cabc43be32649055afd8a1aed41c63d9
    ("ploop: implement PLOOP_IOC_PUSH_BACKUP_IO").
    
    https://jira.sw.ru/browse/PSBM-45000
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 drivers/block/ploop/push_backup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
index 05af67c..056918c 100644
--- a/drivers/block/ploop/push_backup.c
+++ b/drivers/block/ploop/push_backup.c
@@ -466,6 +466,11 @@ int ploop_pb_get_pending(struct ploop_pushbackup_desc *pbd,
 		}
 
                 /* blocking case */
+		if (unlikely(pbd->ppb_waiting)) {
+			/* Other task is already waiting for event */
+			err = -EBUSY;
+			goto get_pending_unlock;
+		}
 		pbd->ppb_waiting = true;
 		spin_unlock(&pbd->ppb_lock);
 


More information about the Devel mailing list