From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCH v2] zram: fix pool name truncation
Date: Wed, 12 Aug 2015 00:43:29 +0900 [thread overview]
Message-ID: <1439307809-914-1-git-send-email-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <1439299983-8070-1-git-send-email-sergey.senozhatsky@gmail.com>
zram_meta_alloc() constructs a pool name for zs_create_pool() call
as
snprintf(pool_name, sizeof(pool_name), "zram%d", device_id);
However, it defines pool name buffer to be only 8 chars long
(minus trailing zero), which means that we can have only 1000
pool names: zram0 -- zram999.
With CONFIG_ZSMALLOC_STAT enabled an attempt to create a device
zram1000 can fail if device zram100 already exists, because
snprintf() will truncate new pool name to zram100 and pass it
to debugfs_create_dir(), causing:
debugfs dir <zram100> creation failed
zram: Error creating memory pool
... and so on (zram101 - zram1010, etc).
Fix it by increasing pool_name buffer size to 15:
-- zram prefix (length 4)
-- int device_id can use up to 10 chars
-- terminating zero byte
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
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 b088ca9..1dec01d 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -502,7 +502,7 @@ static void zram_meta_free(struct zram_meta *meta, u64 disksize)
static struct zram_meta *zram_meta_alloc(int device_id, u64 disksize)
{
size_t num_pages;
- char pool_name[8];
+ char pool_name[15];
struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL);
if (!meta)
--
2.5.0
next prev parent reply other threads:[~2015-08-11 15:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 13:33 [PATCH 4.2] zram: fix pool names truncation Sergey Senozhatsky
2015-08-11 13:33 ` [PATCH] zram: fix max pool limitation Sergey Senozhatsky
2015-08-11 14:38 ` Sergey Senozhatsky
2015-08-11 15:43 ` Sergey Senozhatsky [this message]
2015-08-12 13:30 ` [PATCH 4.2] zram: fix pool names truncation Sergey Senozhatsky
2015-08-12 13:32 ` [PATCH v3] zram: fix pool name truncation Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439307809-914-1-git-send-email-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome