aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2012-06-06 19:35:55 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-26 11:38:24 -0800
commitf4d29a959aa619f3d46e2b685cfb8acac41503db (patch)
tree58c304c854c909c6143a2be3055353db624e3dc3 /net
parent6b71f61c321b1fe8d35b75ab573ff46c51e59acc (diff)
libceph: fix overflow in osdmap_apply_incremental()
(cherry picked from commit a5506049500b30dbc5edb4d07a3577477c1f3643) On 32-bit systems, a large `pglen' would overflow `pglen*sizeof(u32)' and bypass the check ceph_decode_need(p, end, pglen*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> Reviewed-by: Alex Elder <elder@inktank.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/osdmap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index a38ce3f5695..c77133405ff 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -900,6 +900,10 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
(void) __remove_pg_mapping(&map->pg_temp, pgid);
/* insert */
+ if (pglen > (UINT_MAX - sizeof(*pg)) / sizeof(u32)) {
+ err = -EINVAL;
+ goto bad;
+ }
pg = kmalloc(sizeof(*pg) + sizeof(u32)*pglen, GFP_NOFS);
if (!pg) {
err = -ENOMEM;