[PATCH] bad bd_fsfreeze_count in freeze_bdev

From: Chuck Coffing
Date: Fri Sep 13 2013 - 22:37:41 EST


Hi,

An error path in freeze_bdev screws up the freeze count.

Consider:
- call freeze_bdev with a bdev that's unmounted (stupidity or a race)
- bd_fsfreeze_count is unconditionally incremented on entry
- can't get the sb; error out
- bd_fsfreeze_count is not decremented (oops!)
- call freeze_bdev again just for obnoxiousness...
- since bd_fsfreeze_count is already nonzero, sb is assumed good and deref'd

(CC me, I'm not subscribed)


diff --git a/fs/block_dev.c b/fs/block_dev.c
index c3549ed..f1c5561 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -253,6 +253,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
}
deactivate_super(sb);
out:
+ bdev->bd_fsfreeze_count--;
sync_blockdev(bdev);
mutex_unlock(&bdev->bd_fsfreeze_mutex);
return sb; /* thaw_bdev releases s->s_umount */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/