Potential memory hazard due to AlignedBuffer& AlignedBuffer::operator=(&&)
Categories
(Core :: Audio/Video: Playback, defect)
Tracking
()
People
(Reporter: mozillabugs, Assigned: aosmond)
Details
(Keywords: reporter-external, sec-moderate, Whiteboard: [adv-main125+][adv-esr115.10+])
Attachments
(2 files)
48 bytes,
text/x-phabricator-request
|
diannaS
:
approval-mozilla-release-
RyanVM
:
approval-mozilla-esr115+
|
Details | Review |
213 bytes,
text/plain
|
Details |
AlignedBuffer& operator=(&&)
(dom/media/MediaData.h
) creates an invalid member UniquePtr<uint8_t[]> mBuffer
on self-move. The bug is that it doesn't check for self-move before calling ~AlignedBuffer()
, which invalidates the entire object. (Following code from FIREFOX_122_0_RELEASE
):
97: AlignedBuffer& operator=(AlignedBuffer&& aOther) noexcept {
98: this->~AlignedBuffer();
99: new (this) AlignedBuffer(std::move(aOther));
100: return *this;
101: }
Line 99 then constructs a new object from the invalid object using the move constructor:
87: AlignedBuffer(AlignedBuffer&& aOther) noexcept
88: : mData(aOther.mData),
89: mLength(aOther.mLength),
90: mBuffer(std::move(aOther.mBuffer)),
91: mCapacity(aOther.mCapacity) {
92: aOther.mData = nullptr;
93: aOther.mLength = 0;
94: aOther.mCapacity = 0;
95: }
but the mBuffer
member:
246: UniquePtr<uint8_t[]> mBuffer;
is never reinitialized, and thus retains the invalid value it received on line 98 (and which got moved to itself on line 90). That value eventually will get used by ~UniquePtr<uint8_t[]>()
, possibly releasing memory it doesn't own.
I don't know whether any code actually does a self-move.
https://bugzilla.mozilla.org/show_bug.cgi?id=1815108 might be related to this bug.
Reporter | ||
Updated•1 year ago
|
Updated•1 year ago
|
![]() |
||
Updated•1 year ago
|
![]() |
||
Updated•1 year ago
|
![]() |
||
Updated•1 year ago
|
![]() |
||
Updated•1 year ago
|
Assignee | ||
Comment 1•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Comment 2•1 year ago
|
||
There is a lot of code to cover, so I am not 100% certain, but I think this is theoretical, since this isn't a useful pattern for us to replicate in general. We are usually moving the AlignedBuffer objects from one part of the pipeline to another, and so we don't actually run the risk of moving into itself. It is easy enough to fix though this and make the code very clear/simple.
Updated•1 year ago
|
Assignee | ||
Comment 3•1 year ago
|
||
Comment on attachment 9389750 [details]
Bug 1883158.
Beta/Release Uplift Approval Request
- User impact if declined: Sec issue
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Trivial change to correct move operator in the case of self move, now works exactly the same as the move constructor.
- String changes made/needed:
- Is Android affected?: Yes
Comment 5•1 year ago
|
||
Comment on attachment 9389750 [details]
Bug 1883158.
This is too late and doesn't seem critical. We have already started building an RC .
![]() |
||
Comment 6•1 year ago
|
||
Reporter | ||
Updated•1 year ago
|
Updated•1 year ago
|
Updated•11 months ago
|
Comment 7•11 months ago
|
||
Please nominate this for ESR115 approval when you get a chance.
Assignee | ||
Comment 8•11 months ago
|
||
Comment on attachment 9389750 [details]
Bug 1883158.
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: Minor sec issue, very low risk
- User impact if declined: Sec issue
- Fix Landed on Version: 125
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Trivial patch making the move operator mirror the move constructor
Comment 9•11 months ago
|
||
Comment on attachment 9389750 [details]
Bug 1883158.
Approved for 115.10esr.
Comment 10•11 months ago
|
||
uplift |
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Comment 11•11 months ago
|
||
Updated•11 months ago
|
Updated•9 months ago
|
Updated•5 months ago
|
Description
•