mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] [PATCH] loop: prevent partial read
@ 2011-01-24 16:43 Dmitry Monakhov
  2011-01-24 16:43 ` [PATCH 2/2] [PATCH] loop: cleanup set_status interface Dmitry Monakhov
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Monakhov @ 2011-01-24 16:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: jaxboe, akpm, Dmitry Monakhov

If read was not fully successful we have to fail whole bio to
prevent information leak.

##Testcase_begin
dd if=/dev/zero of=./tmp 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>
---
 drivers/block/loop.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 49e6a54..32e23f6 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -448,7 +448,8 @@ do_lo_receive(struct loop_device *lo,
 
 	if (retval < 0)
 		return retval;
-
+	if (retval != bvec->bv_len)
+		return -EIO;
 	return 0;
 }
 
-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-24 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24 16:43 [PATCH 1/2] [PATCH] loop: prevent partial read Dmitry Monakhov
2011-01-24 16:43 ` [PATCH 2/2] [PATCH] loop: cleanup set_status interface Dmitry Monakhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®