Skip to content

Commit

Permalink
Merge pull request #8401: hammer: Protect against excessively large o…
Browse files Browse the repository at this point in the history
…bject map sizes

Reviewed-by: Loic Dachary <ldachary@redhat.com>
  • Loading branch information
Loic Dachary committed Apr 5, 2016
2 parents 47884ea + 97f474f commit ce7ef8d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cls/rbd/cls_rbd.cc
Expand Up @@ -104,6 +104,7 @@ cls_method_handle_t h_old_snapshot_remove;
#define RBD_SNAP_KEY_PREFIX "snapshot_"
#define RBD_DIR_ID_KEY_PREFIX "id_"
#define RBD_DIR_NAME_KEY_PREFIX "name_"
#define RBD_MAX_OBJECT_MAP_OBJECT_COUNT 256000000

static int snap_read_header(cls_method_context_t hctx, bufferlist& bl)
{
Expand Down Expand Up @@ -1996,6 +1997,12 @@ int object_map_resize(cls_method_context_t hctx, bufferlist *in, bufferlist *out
return -EINVAL;
}

// protect against excessive memory requirements
if (object_count > RBD_MAX_OBJECT_MAP_OBJECT_COUNT) {
CLS_ERR("object map too large: %" PRIu64, object_count);
return -EINVAL;
}

BitVector<2> object_map;
int r = object_map_read(hctx, object_map);
if ((r < 0) && (r != -ENOENT)) {
Expand Down

0 comments on commit ce7ef8d

Please sign in to comment.