From: Dmitry Monakhov Date: Tue, 8 Nov 2011 00:20:06 +0000 (+1100) Subject: loop: prevent information leak after failed read X-Git-Tag: next-20111114~2^2~53 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=8bf1846903f26ba84c9f28e696c53766f94c9466;p=karo-tx-linux.git loop: prevent information leak after failed read 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 Cc: Jens Axboe Signed-off-by: Andrew Morton --- diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 3d806820280e..0d567397c254 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -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; }