aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/zram
diff options
context:
space:
mode:
authorRobert Jennings <rcj@linux.vnet.ibm.com>2011-01-28 09:00:42 -0600
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-04 13:29:12 -0800
commit2787f959d6c5fb258d964218ac75346019f49ee9 (patch)
treed932cc65658d024ee554609eff5d48189b011a0e /drivers/staging/zram
parent37700965858a099d250bca531ca1c99b22c8708d (diff)
zram: Return zero'd pages on new reads
Currently zram will do nothing to the page in the bvec when that page has not been previously written. This allows random data to leak to user space. That can be seen by doing the following: ## Load the module and create a 256Mb zram device called /dev/zram0 # modprobe zram # echo $((256*1024*1024)) > /sys/class/block/zram0/disksize ## Initialize the device by writing zero to the first block # dd if=/dev/zero of=/dev/zram0 bs=512 count=1 ## Read ~256Mb of memory into a file and hope for something interesting # dd if=/dev/zram0 of=file This patch will treat an unwritten page as a zero-filled page. If a page is read before a write has occurred the data returned is all 0's. Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com> Reviewed-by: Pekka Enberg <penberg@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/zram')
-rw-r--r--drivers/staging/zram/zram_drv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 7d11c595c7d..1017d6df17d 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -237,7 +237,7 @@ static void zram_read(struct zram *zram, struct bio *bio)
if (unlikely(!zram->table[index].page)) {
pr_debug("Read before write: sector=%lu, size=%u",
(ulong)(bio->bi_sector), bio->bi_size);
- /* Do nothing */
+ handle_zero_page(page);
continue;
}