[Devel] [PATCH rh7 04/38] ploop: prevent dangerous ploop-umount

Andrey Smetanin asmetanin at virtuozzo.com
Fri May 15 09:48:05 PDT 2015


Umounting ploop device if inner fs is still mounted on it leads to
numerous complains in kernel logs like:

VFS: Busy inodes after unmount. sb = ffff880108987000, fs type = ext4, sb count = 2, sb->s_root = /

and is not what user expected. The patch adds some protection from dummy
userspace mistakes: do not allow to stop ploop device (this is the first step
of ploop-umount) if user uses /dev/ploopNp1 for ioctl, or if someone (inner fs)
is still using the device.

https://jira.sw.ru/browse/PSBM-21474

Signed-off-by: Maxim Patlasov <MPatlasov at parallels.com>
---
 drivers/block/ploop/dev.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 5a3a5ec..2f4928d 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -3548,6 +3548,20 @@ static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
 	struct ploop_delta * delta;
 	int cnt;
 
+	if (bdev != bdev->bd_contains) {
+		if (printk_ratelimit())
+			printk(KERN_INFO "stop ploop%d failed (wrong bdev)\n",
+			       plo->index);
+		return -ENODEV;
+	}
+
+	if (bdev->bd_contains->bd_holders) {
+		if (printk_ratelimit())
+			printk(KERN_INFO "stop ploop%d failed (holders=%d)\n",
+			       plo->index, bdev->bd_contains->bd_holders);
+		return -EBUSY;
+	}
+
 	if (!test_bit(PLOOP_S_RUNNING, &plo->state))
 		return -EINVAL;
 
-- 
1.9.3




More information about the Devel mailing list