linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] zram: fix operator precedence to get offset
@ 2017-04-13  0:17 Minchan Kim
  2017-04-13  0:17 ` [PATCH 2/3] zram: do not use copy_page with non-page alinged address Minchan Kim
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Minchan Kim @ 2017-04-13  0:17 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Sergey Senozhatsky, kernel-team, Minchan Kim, stable

In zram_rw_page, the logic to get offset is wrong by operator precedence
(i.e., "<<" is higher than "&"). With wrong offset, zram can corrupt the
user's data. This patch fixes it.

Fixes: 8c7f01025 ("zram: implement rw_page operation of zram")
Cc: stable@vger.kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 drivers/block/zram/zram_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 9e2199060040..83c38a123242 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -930,7 +930,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector,
 	}
 
 	index = sector >> SECTORS_PER_PAGE_SHIFT;
-	offset = sector & (SECTORS_PER_PAGE - 1) << SECTOR_SHIFT;
+	offset = (sector & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT;
 
 	bv.bv_page = page;
 	bv.bv_len = PAGE_SIZE;
-- 
2.7.4

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

end of thread, other threads:[~2017-04-18  2:48 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13  0:17 [PATCH 1/3] zram: fix operator precedence to get offset Minchan Kim
2017-04-13  0:17 ` [PATCH 2/3] zram: do not use copy_page with non-page alinged address Minchan Kim
2017-04-14  5:41   ` Sergey Senozhatsky
2017-04-14 15:40     ` Minchan Kim
2017-04-17  1:48   ` Sergey Senozhatsky
2017-04-13  0:17 ` [PATCH 3/3] zsmalloc: expand class bit Minchan Kim
2017-04-14  5:07 ` [PATCH 1/3] zram: fix operator precedence to get offset Sergey Senozhatsky
2017-04-14 15:33   ` Minchan Kim
2017-04-17  1:21     ` Sergey Senozhatsky
2017-04-17  1:54       ` Sergey Senozhatsky
2017-04-17  2:14         ` Minchan Kim
2017-04-17 10:50           ` Sergey Senozhatsky
2017-04-17 10:53             ` Sergey Senozhatsky
2017-04-17 23:53             ` Minchan Kim
2017-04-18  1:53               ` Sergey Senozhatsky
2017-04-18  2:47                 ` Minchan Kim
2017-04-17  1:21 ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).