[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <d10cdf1d-4a67-48df-b389-3a51f60e9431@linux.dev>
Date: Mon, 6 Nov 2023 22:54:28 +0300
From: Vasily Averin <vasily.averin@...ux.dev>
To: Sergey Senozhatsky <senozhatsky@...omium.org>,
Minchan Kim <minchan@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
zhouxianrong <zhouxianrong@...wei.com>
Subject: [PATCH] zram: unsafe zram_get_element call in zram_read_page()
Taken lock is required to access the content of zram entry.
Fixes: 8e19d540d107 ("zram: extend zero pages to same element pages")
Signed-off-by: Vasily Averin <vasily.averin@...ux.dev>
---
drivers/block/zram/zram_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index d77d3664ca08..9ac3d4e51d26 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1362,14 +1362,14 @@ static int zram_read_page(struct zram *zram, struct page *page, u32 index,
ret = zram_read_from_zspool(zram, page, index);
zram_slot_unlock(zram, index);
} else {
+ unsigned long entry = zram_get_element(zram, index);
/*
* The slot should be unlocked before reading from the backing
* device.
*/
zram_slot_unlock(zram, index);
- ret = read_from_bdev(zram, page, zram_get_element(zram, index),
- parent);
+ ret = read_from_bdev(zram, page, entry, parent);
}
/* Should NEVER happen. Return bio error if it does. */
--
2.34.1
Powered by blists - more mailing lists