zram: off by one in read_block_state()
Subsystems (3)
PATCH 1/1 zram: off by one in read_block_state()
The snprintf() function 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")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/block/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +1 -1
@@ -910,7 +910,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,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 ; }
Signature · 1 line
2.20.1