rbd: make snap_names_len a u64
authorAlex Elder <elder@inktank.com>
Thu, 2 Aug 2012 16:29:44 +0000 (11:29 -0500)
committerAlex Elder <elder@inktank.com>
Mon, 1 Oct 2012 19:30:48 +0000 (14:30 -0500)
The snap_names_len field of an rbd_image_header structure is defined
with type size_t.  That field is used as both the source and target
of 64-bit byte-order swapping operations though, so it's best to
define it with type u64 instead.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c

index bf418a6afbe073cc838d1fdff4df2d84d6653088..02de524d4b679903ccbeb213fdeabd34abb8c4a2 100644 (file)
@@ -81,7 +81,7 @@ struct rbd_image_header {
        __u8 crypt_type;
        __u8 comp_type;
        struct ceph_snap_context *snapc;
-       size_t snap_names_len;
+       u64 snap_names_len;
        u32 total_snaps;
 
        char *snap_names;
@@ -510,6 +510,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
 
        if (snap_count) {
                header->snap_names_len = le64_to_cpu(ondisk->snap_names_len);
+               BUG_ON(header->snap_names_len > (u64) SIZE_MAX);
                header->snap_names = kmalloc(header->snap_names_len,
                                             GFP_KERNEL);
                if (!header->snap_names)