]> git.karo-electronics.de Git - linux-beck.git/commitdiff
libceph: fix crush_decode() call site in osdmap_decode()
authorIlya Dryomov <ilya.dryomov@inktank.com>
Thu, 13 Mar 2014 14:36:15 +0000 (16:36 +0200)
committerSage Weil <sage@inktank.com>
Sat, 5 Apr 2014 04:07:43 +0000 (21:07 -0700)
The size of the memory area feeded to crush_decode() should be limited
not only by osdmap end, but also by the crush map length.  Also, drop
unnecessary dout() (dout() in crush_decode() conveys the same info) and
step past crush map only if it is decoded successfully.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Alex Elder <elder@linaro.org>
net/ceph/osdmap.c

index c39ac624ccc347e57e3bd5197d6bb26ba03e5629..d4a6b0df3627cdc6d59c70dfe59d67d007021ff2 100644 (file)
@@ -802,16 +802,13 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map)
 
        /* crush */
        ceph_decode_32_safe(p, end, len, e_inval);
-       dout("osdmap_decode crush len %d from off 0x%x\n", len,
-            (int)(*p - start));
-       ceph_decode_need(p, end, len, e_inval);
-       map->crush = crush_decode(*p, end);
-       *p += len;
+       map->crush = crush_decode(*p, min(*p + len, end));
        if (IS_ERR(map->crush)) {
                err = PTR_ERR(map->crush);
                map->crush = NULL;
                goto bad;
        }
+       *p += len;
 
        /* ignore the rest */
        *p = end;