Project

General

Profile

Bug #5152

/dev/random cache leads to duplicate uuids after fork

Added by Jon Tibble about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
Category:
lib - userland libraries
Start date:
2014-09-11
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

Copied and pasted from an email to the userland list:
-------
I just would like to draw attention to this patch: https://github.com/illumos/illumos-gate/commit/84615402a46a91be66843bd64e4fb72642b06e9d

After this patch some programs may start generating duplicated UUID.

Here is scenario to demonstrate the difference between patched and non-patched version:

#!/usr/bin/perl
use UUID;

sub get_new_uuid {
UUID::generate(my $uuid);
UUID::unparse($uuid, my $string);
return $string;
}

my $u = get_new_uuid();

unless (fork) {
print get_new_uuid() . "\\n";
exit;
}

unless (fork) {
print get_new_uuid() . "\\n";
exit;
}

sleep 1;

Output without patch:
cc9b9de4-8c0e-4885-d9a1-81b96a8b7e18
1470cbb2-a979-66c7-cd4d-e15aea3c2ccc

Output with patch:
b2b01b94-133e-4ceb-8c3c-d804a380a477
b2b01b94-133e-4ceb-8c3c-d804a380a477

Regards,
Alexey Komarov

History

#1

Updated by Robert Mustacchi about 5 years ago

  • Subject changed from Duplicate UUIDs following #4430 to /dev/random cache leads to duplicate uuids after fork
  • Category set to lib - userland libraries
  • Status changed from New to Pending RTI
  • Assignee set to Jerry Jelinek
  • % Done changed from 0 to 100
  • Tags deleted (needs-triage)

The root cause here is that we're not clearing out the cache inbetween forks. A simple atfork handler will do the trick.

#2

Updated by Electric Monk about 5 years ago

  • Status changed from Pending RTI to Closed

git commit 2bcedfbf993c2cb7f5e7588f579acc5a80a1080f

commit  2bcedfbf993c2cb7f5e7588f579acc5a80a1080f
Author: Jerry Jelinek <jerry.jelinek@joyent.com>
Date:   2014-09-16T15:31:33.000Z

    5152 /dev/random cache leads to duplicate uuids after fork
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Approved by: Dan McDonald <danmcd@omniti.com>

Also available in: Atom PDF