mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + zram-off-by-one-in-read_block_state.patch added to -mm tree
@ 2021-09-16 19:02 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2021-09-16 19:02 UTC (permalink / raw)
  To: dan.carpenter, minchan, mm-commits, senozhatsky


The patch titled
     Subject: zram: off by one in read_block_state()
has been added to the -mm tree.  Its filename is
     zram-off-by-one-in-read_block_state.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/zram-off-by-one-in-read_block_state.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/zram-off-by-one-in-read_block_state.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Dan Carpenter <dan.carpenter@oracle.com>
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.

Link: https://lkml.kernel.org/r/20210916130404.GA25094@kili
Fixes: c0265342bff4 ("zram: introduce zram memory tracking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/block/zram/zram_drv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/block/zram/zram_drv.c~zram-off-by-one-in-read_block_state
+++ a/drivers/block/zram/zram_drv.c
@@ -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 dan.carpenter@oracle.com are

zram-off-by-one-in-read_block_state.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-16 19:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 19:02 + zram-off-by-one-in-read_block_state.patch added to -mm tree akpm

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).