From: Tomas Bortoli <tomasbortoli@gmail.com>
To: dhowells@redhat.com
Cc: linux-cachefs@redhat.com, linux-kernel@vger.kernel.org,
syzkaller@googlegroups.com,
Tomas Bortoli <tomasbortoli@gmail.com>
Subject: [PATCH] fscache: fscache_set_key() - align alloc and usage
Date: Sun, 22 Jul 2018 13:05:19 +0200 [thread overview]
Message-ID: <20180722110519.23917-1-tomasbortoli@gmail.com> (raw)
The fscache_set_key() function allocates the buf pointer if index_key_len > sizeof(cookie->inline_key).
In such cases the allocated space might not be aligned with the pointer type.
This may result in an out-of-bound in the for-loop later in the same function, as the counter is rounded up.
Signed-off-by: Tomas Bortoli <tomasbortoli@gmail.com>
Reported-by: syzbot+a95b989b2dde8e806af8@syzkaller.appspotmail.com
---
fs/fscache/cookie.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 97137d7ec5ee..ed28bfb6a0fe 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -98,7 +98,7 @@ static int fscache_set_key(struct fscache_cookie *cookie,
cookie->key_len = index_key_len;
if (index_key_len > sizeof(cookie->inline_key)) {
- buf = kzalloc(index_key_len, GFP_KERNEL);
+ buf = kzalloc(round_up(index_key_len, sizeof(u32)), GFP_KERNEL);
if (!buf)
return -ENOMEM;
cookie->key = buf;
--
2.11.0
next reply other threads:[~2018-07-22 11:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-22 11:05 Tomas Bortoli [this message]
2018-08-03 13:49 ` David Howells
2018-08-03 17:26 ` Tomas Bortoli
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=20180722110519.23917-1-tomasbortoli@gmail.com \
--to=tomasbortoli@gmail.com \
--cc=dhowells@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller@googlegroups.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