Closed
Bug 1223909
Opened 10 years ago
Closed 6 years ago
Atomic32::operator += and -= have non-canonical implementation
Categories
(Core :: WebRTC, defect, P3)
Tracking
()
RESOLVED
INCOMPLETE
| backlog | webrtc/webaudio+ |
People
(Reporter: q1, Unassigned)
Details
(Keywords: sec-audit)
The Windows versions of Atomic32::operator += and operator -= (media\webrtc\trunk\webrtc\system_wrappers\source\atomic32_win.cc) have non-canonical implementations. They return the per-operation value, not the post-operation value. This implementation is also at odds with the Unix and Mac implementations of the same class, which return the post-operation value (see atomic32_posix.cc and atomic32_mac.cc).
If these functions are used for, e.g., reference counting, this error could cause a security bug, hence I've filed it that way.
Details
-------
41: int32_t Atomic32::operator+=(int32_t value) {
42: return InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(&value_),
43: value);
44: }
45:
46: int32_t Atomic32::operator-=(int32_t value) {
47: return InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(&value_),
48: -value);
49: }
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683597%28v=vs.85%29.aspx :
------
LONG __cdecl InterlockedExchangeAdd(
_Inout_ LONG volatile *Addend,
_In_ LONG Value
);
...
The function returns the initial value of the Addend parameter.
------
Updated•10 years ago
|
Group: core-security → media-core-security
Comment 2•10 years ago
|
||
Note: upstream bug.
As best I can tell from auditing all the uses of Atomic32 (using m-c), none of them use += or -=. They all use ++ and --. So while this might the a latent problem, there appears to be no actual issue here.
Keywords: sec-audit
(In reply to Randell Jesup [:jesup] from comment #2)
> Note: upstream bug.
>
> As best I can tell from auditing all the uses of Atomic32 (using m-c), none
> of them use += or -=. They all use ++ and --. So while this might the a
> latent problem, there appears to be no actual issue here.
+= is used by Atomic32::Value() (atomic32.h) at least, although that case uses the expression |*this += 0|, so this bug doesn't change the result. Oddly, DXR finds that call only for the Posix atomic32.cc implementation, even though it exists in the .h file. DXR doesn't find any callers for -=, FWIW.
Updated•10 years ago
|
backlog: --- → webrtc/webaudio+
Rank: 25
Priority: -- → P2
Comment 5•10 years ago
|
||
(In reply to q1 from comment #4)
> > using m-c
>
> What's that tool?
m-c is short for mozilla-central. I grepped all uses of Atomic32, then looked at all uses of those variables in the code.
Simplest would be to delete the impls and see if it still links.
> Simplest would be to delete the impls and see if it still links.
The link succeeds on -=, but fails on undefined += via the call in Atomic32::Value(). If you replace the contents of Value() with |return 0;|, it links, so that's the only current use, so the bug is latent.
Comment 7•8 years ago
|
||
Mass change P3->P4 to align with new Mozilla triage process.
Priority: P2 → P3
Comment 8•6 years ago
|
||
This code has been rewritten since the bug was filed.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INCOMPLETE
Updated•2 years ago
|
Group: media-core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•