Skip to content

Theoretical (astronomically small) possibility of uninitialized read in GetRdRand()? #17313

@practicalswift

Description

@practicalswift

From uint64_t GetRdRand() noexcept :

bitcoin/src/random.cpp

Lines 145 to 150 in 0d6b6b7

uint64_t r1;
for (int i = 0; i < 10; ++i) {
__asm__ volatile (".byte 0x48, 0x0f, 0xc7, 0xf0; setc %1" : "=a"(r1), "=q"(ok) :: "cc"); // rdrand %rax
if (ok) break;
}
return r1;

In the case of ten RdRand failures in a row: wouldn't r1 be read uninitialized on L150? (If so, then the same goes for the __i386__ case a couple of lines above.)

It should be noted that the odds of ten RdRand failures in a row are astronomically small, so I don't think this is urgent at all. Would be nice to rule out the theoretical possibility though (if such a possibility exists).

Friendly ping @sipa :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions