Closed
Bug 335549
Opened 19 years ago
Closed 19 years ago
[FIX]UUID generator is nonrandom on x86-64
Categories
(Core :: XPCOM, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: benjamin, Assigned: bzbarsky)
References
Details
(Keywords: fixed1.8.1)
Attachments
(1 file)
|
1.15 KB,
patch
|
vlad
:
review+
roc
:
superreview+
mtschrep
:
approval1.8.1+
|
Details | Diff | Splinter Review |
On my FC4 x86-64 box, I frequently see this error: Security Error: Content at moz-nullprincipal:{00000000-0000-4000-8000-000000000000} may not load or link to http://fxfeeds.mozilla.org/rss20.xml
This error is apparently pretty normal, but the ID is not: it should be random, and it's consistently the same number. bz thinks this is probably due to x86-64
| Assignee | ||
Comment 1•19 years ago
|
||
So the "4000" comes from:
155 id->m2 |= 0x4000;
and the "8000" comes from:
159 id->m3[0] |= 0x80;
in the UUID generator. So the actual "random" UUID we generate is 0 everywhere.
Benjamin, would you be willing to step through nsUUIDGenerator::GenerateUUIDInPlace and check the following:
1) The value returned by the call to random() (as hex)
2) The value of mRBytes
3) The value of sizeof(rval)
| Assignee | ||
Updated•19 years ago
|
Severity: major → critical
Flags: blocking1.9a1?
| Reporter | ||
Comment 2•19 years ago
|
||
> 1) The value returned by the call to random() (as hex)
(gdb) p/x rval
$36 = 0x4fa7a4f
> 2) The value of mRBytes
(gdb) p mRBytes
$37 = 3 '\003'
> 3) The value of sizeof(rval)
(gdb) p sizeof(rval)
$34 = 8
| Reporter | ||
Comment 3•19 years ago
|
||
So, it seems that random() only returns a 4-byte number, but we pretend it's an 8-byte number. Then, we only use the last three bytes, which are all zero?
| Assignee | ||
Comment 4•19 years ago
|
||
That's what it looks like, yes. We should probably be using the mRBytes low bytes, not the mRBytes high bytes (the latter is what we do right now), no?
| Assignee | ||
Comment 5•19 years ago
|
||
So replace:
141 PRUint8 *src = (PRUint8*)&rval;
142 #ifdef IS_LITTLE_ENDIAN
143 src += sizeof(rval) - mRBytes;
144 #endif
with:
// Read the least significant mRBytes bytes of rval
PRUint8 *src = (PRUint8*)&rval;
#ifdef IS_BIG_ENDIAN
src += sizeof(rval) - mRBytes;
#endif
Does doing that work?
And then before we do the "153 /* Put in the version */" thing, we should check whether the resulting ID is all zeros; if so, NS_ERROR and throw so these things are easier to catch.
| Assignee | ||
Comment 6•19 years ago
|
||
Benjamin, could you maybe verify that this works?
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Attachment #220227 -
Flags: superreview?(roc)
Attachment #220227 -
Flags: review?(vladimir)
| Assignee | ||
Updated•19 years ago
|
Priority: -- → P1
Summary: UUID generator is nonrandom on x86-64 → [FIX]UUID generator is nonrandom on x86-64
Attachment #220227 -
Flags: superreview?(roc) → superreview+
| Assignee | ||
Updated•19 years ago
|
Flags: blocking1.9a1? → blocking1.9a1+
Attachment #220227 -
Flags: review?(vladimir) → review+
| Assignee | ||
Comment 7•19 years ago
|
||
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 8•19 years ago
|
||
*** Bug 347300 has been marked as a duplicate of this bug. ***
Comment 9•19 years ago
|
||
This bug also exists on the 1.8.1 branch, are there plans to move the patch to the branch?
| Assignee | ||
Comment 10•19 years ago
|
||
Er.... I didn't realize this had gotten landed on branch. Yeah, we should probably take this, as well as the various other fixes to the UUID generator on branch. :(
Flags: blocking1.8.1?
| Assignee | ||
Updated•19 years ago
|
Attachment #220227 -
Flags: approval1.8.1?
Comment 11•19 years ago
|
||
Comment on attachment 220227 [details] [diff] [review]
Proposed patch
a=schrep for drivers.
Attachment #220227 -
Flags: approval1.8.1? → approval1.8.1+
| Assignee | ||
Updated•19 years ago
|
Flags: blocking1.8.1?
You need to log in
before you can comment on or make changes to this bug.
Description
•