Skip to contentSkip to conversation

zram-off-by-one-in-read_block_state.patch removed from -mm tree

merged [email protected] 1 participant 1 message Nov 11, 2021

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: zram: off by one in read_block_state()
has been removed from the -mm tree. Its filename was
zram-off-by-one-in-read_block_state.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Dan Carpenter <[email protected]>
Subject: zram: off by one in read_block_state()

snprintf() returns the number of bytes it would have printed if there were space. But it does not count the NUL terminator. So that means that if "count == copied" then this has already overflowed by one character.

This bug likely isn't super harmful in real life.

Fixes c0265342bff4 ("zram: introduce zram memory tracking")
Cc Minchan Kim <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---

 drivers/block/zram/zram_drv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zram/zram_drv.c renamed from drivers/block/zram/zram_drv.c~zram-off-by-one-in-read_block_state +1 -1
@@ -910,7 +910,7 @@ static ssize_t read_block_state(struct f
 			zram_test_flag(zram, index, ZRAM_HUGE) ? 'h' : '.',
 			zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.');
 
-		if (count < copied) {
+		if (count <= copied) {
 			zram_slot_unlock(zram, index);
 			break;
 		}

_

Patches currently in -mm which might be from [email protected] are