]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
loop: prevent information leak after failed read
authorDmitry Monakhov <dmonakhov@openvz.org>
Wed, 16 Nov 2011 08:21:48 +0000 (09:21 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 16 Nov 2011 08:21:48 +0000 (09:21 +0100)
If read was not fully successful we have to fail whole bio to prevent
information leak of old pages

##Testcase_begin
dd if=/dev/zero of=./file bs=1M count=1
losetup /dev/loop0 ./file -o 4096
truncate -s 0 ./file
# OOps loop offset is now beyond i_size, so read will silently fail.
# So bio's pages would not be cleared, may which result in information leak.
hexdump -C /dev/loop0
##testcase_end

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c

index 3d806820280e3bc4aaa5e81d6bea411f6597e400..0d567397c254e98d04ed0e251d67f3cc59ebd547 100644 (file)
@@ -372,7 +372,8 @@ do_lo_receive(struct loop_device *lo,
 
        if (retval < 0)
                return retval;
-
+       if (retval != bvec->bv_len)
+               return -EIO;
        return 0;
 }