From 5509c802b7c690aaaa9f7cf5ac96161fb1c7247b Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Wed, 5 Oct 2011 11:42:39 +1100 Subject: [PATCH] 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 --- drivers/block/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index aa65eedaad9d..d0d080a600d6 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -449,7 +449,8 @@ do_lo_receive(struct loop_device *lo, if (retval < 0) return retval; - + if (retval != bvec->bv_len) + return -EIO; return 0; } -- 2.39.5