From: Xi Wang <xi.wang@gmail.com>
To: Alex Elder <elder@dreamhost.com>, Sage Weil <sage@newdream.net>
Cc: ceph-devel@vger.kernel.org, Xi Wang <xi.wang@gmail.com>
Subject: [PATCH 2/3] libceph: fix overflow in osdmap_decode()
Date: Sun, 29 Apr 2012 02:59:24 -0400 [thread overview]
Message-ID: <1335682765-1643-2-git-send-email-xi.wang@gmail.com> (raw)
In-Reply-To: <1335682765-1643-1-git-send-email-xi.wang@gmail.com>
On 32-bit systems, a large `n' would overflow `n * sizeof(u32)' and bypass
the check ceph_decode_need(p, end, n * sizeof(u32), bad). It would also
overflow the subsequent kmalloc() size, leading to out-of-bounds write.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
net/ceph/osdmap.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index f80afc3..774eac6 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -670,6 +670,9 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
ceph_decode_need(p, end, sizeof(u32) + sizeof(u64), bad);
ceph_decode_copy(p, &pgid, sizeof(pgid));
n = ceph_decode_32(p);
+ err = -EINVAL;
+ if (n > (UINT_MAX - sizeof(*pg)) / sizeof(u32))
+ goto bad;
ceph_decode_need(p, end, n * sizeof(u32), bad);
err = -ENOMEM;
pg = kmalloc(sizeof(*pg) + n*sizeof(u32), GFP_NOFS);
--
1.7.5.4
next prev parent reply other threads:[~2012-04-29 7:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 6:59 [PATCH 1/3] ligceph: fix overflow in __decode_pool_names() Xi Wang
2012-04-29 6:59 ` Xi Wang [this message]
2012-06-06 16:26 ` [PATCH 2/3] libceph: fix overflow in osdmap_decode() Alex Elder
2012-06-06 17:56 ` Xi Wang
2012-06-06 19:14 ` Alex Elder
2012-06-06 19:20 ` Xi Wang
2012-04-29 6:59 ` [PATCH 3/3] libceph: fix overflow in osdmap_apply_incremental() Xi Wang
2012-06-06 16:26 ` Alex Elder
2012-04-29 7:07 ` [PATCH v2 1/3] libceph: fix overflow in __decode_pool_names() Xi Wang
2012-06-06 16:26 ` Alex Elder
2012-06-06 17:54 ` Xi Wang
2012-06-06 19:14 ` Alex Elder
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=1335682765-1643-2-git-send-email-xi.wang@gmail.com \
--to=xi.wang@gmail.com \
--cc=ceph-devel@vger.kernel.org \
--cc=elder@dreamhost.com \
--cc=sage@newdream.net \
/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