]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
fs/block_dev: fix potential NULL ptr deref in freeze_bdev()
authorAndrey Ryabinin <aryabinin@virtuozzo.com>
Tue, 23 Aug 2016 15:55:31 +0000 (18:55 +0300)
committerJens Axboe <axboe@fb.com>
Thu, 25 Aug 2016 14:38:26 +0000 (08:38 -0600)
Calling freeze_bdev() twice on the same block device without mounted
filesystem get_super() will return NULL, which will lead to NULL-ptr
dereference later in drop_super().

Check get_super() result to fix that.

Note, that this is a purely theoretical issue. We have only 3
freeze_bdev() callers. 2 of them are in filesystem code and used on a
device with mounted fs. The third one in lock_fs() has protection in
upper-layer code against freezing block device the second time without
thawing it first.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/block_dev.c

index e17bdbdfe9b1cf17e721203f8942c127df742fcf..08ae99343d92f91586b49fbf56367906855415ff 100644 (file)
@@ -249,7 +249,8 @@ struct super_block *freeze_bdev(struct block_device *bdev)
                 * thaw_bdev drops it.
                 */
                sb = get_super(bdev);
-               drop_super(sb);
+               if (sb)
+                       drop_super(sb);
                mutex_unlock(&bdev->bd_fsfreeze_mutex);
                return sb;
        }