Project

General

Profile

Bug #37280

librbd's generate_image_id() is not so random

Added by Марк Коренберг 3 months ago. Updated 3 months ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
librbd
Target version:
Start date:
11/15/2018
Due date:
% Done:

0%

Source:
Community (user)
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
rbd
Pull request ID:

Description

src/librbd/Utils.cc contains function generate_image_id() used for creating new images ID.

This function uses rand() without prior call to srand(). According to man 3 srand:

If no seed value is provided, the rand() function is automatically seeded with a value of 1

So such random is meaningless.

As a result we have:

rbd_object_map.136084238e1f29.0000000000000d2e
rbd_object_map.143b042ae8944a.0000000000000d39
rbd_object_map.143b042ae8944a.0000000000000d4b
rbd_object_map.162740238e1f29.0000000000000d3b
rbd_object_map.165cb5238e1f29.0000000000000d47
rbd_object_map.16a64f238e1f29.0000000000000d43
rbd_object_map.1ee2e03d1b58ba.0000000000000d28
rbd_object_map.2274e93d1b58ba.0000000000000d3d
rbd_object_map.5e82a2ae8944a.0000000000000d30
rbd_object_map.5fc8a2ae8944a.0000000000000d3f
rbd_object_map.764a4a2ae8944a.0000000000000d25
rbd_object_map.764a4a2ae8944a.0000000000000d32
rbd_object_map.764a4a2ae8944a.0000000000000d4c
rbd_object_map.9b1f82ae8944a.0000000000000d35
rbd_object_map.9b224238e1f29.0000000000000d33
rbd_object_map.adc9e2ae8944a.0000000000000d37
rbd_object_map.ae974238e1f29.0000000000000d49
rbd_object_map.aea34238e1f29.0000000000000d2c
rbd_object_map.aea382ae8944a.0000000000000d2a
rbd_object_map.e31ce238e1f29.0000000000000d41
rbd_object_map.e31e4238e1f29.0000000000000d45

note, last 32 bits (8 last symbols in hex) like "238e1f29" or "2ae8944a". They are the same for different objects.

History

#1 Updated by Марк Коренберг 3 months ago

"They are the same for different objects"

I mean "the same for different RBD images"

#2 Updated by Mykola Golub 3 months ago

  • Status changed from New to Duplicate

Duplicate of #24634. It was not planned to backport though. We might reconsider this?

Also available in: Atom PDF