Closed
Bug 1349527
Opened 8 years ago
Closed 3 years ago
[Static Analysis][Out-of-bounds write] In cubeb_log_message::cubeb_log_message(char const*)
Categories
(Core :: Audio/Video: cubeb, defect, P3)
Tracking
()
RESOLVED
FIXED
People
(Reporter: tristanbourvon, Assigned: tristanbourvon, Mentored)
References
(Blocks 1 open bug)
Details
(Keywords: stale-bug, Whiteboard: CID 1402662)
Attachments
(1 file)
Coverity detected an out-of-bounds write in cubeb_log_message::cubeb_log_message(char const*)
---
Description of the bug
---
> cubeb_log_message(char const str[CUBEB_LOG_MESSAGE_MAX_SIZE])
> {
|str| has size |CUBEB_LOG_MESSAGE_MAX_SIZE|
> size_t length = strlen(str);
|strlen| returns the length of the string EXCLUDING \0
> /* paranoia against malformed message */
> assert(length < CUBEB_LOG_MESSAGE_MAX_SIZE);
> if (length > CUBEB_LOG_MESSAGE_MAX_SIZE - 1) {
> return;
> }
At this point we know that |length < CUBEB_LOG_MESSAGE_MAX_SIZE|
> PodCopy(storage, str, length);
> storage[length + 1] = '\0';
> }
* Knowing that |storage| has size |CUBEB_LOG_MESSAGE_MAX_SIZE|
* if |length == CUBEB_LOG_MESSAGE_MAX_SIZE - 1|
=> then, we write \0 at |storage[CUBEB_LOG_MESSAGE_MAX_SIZE]|, which is out-of-bounds.
---
Possible consequences
---
As |cubeb_log_message|s are stored in a |lock_free_queue|, we could potentially be "emptying" the next message in the queue by setting its first byte to \0.
If the |cubeb_log_message| is at the end of the underlying array of the |lock_free_queue|, we could also be writing \0 to:
* |ring_buffer_base::consumer_id|, if NDEBUG is defined
* The next byte in the .data segment of the program (the |lock_free_queue| lives at the very end of |cubeb_async_logger|, which is instantiated statically) otherwise.
It does not seem useful here to further investigate how this could be exploited.
---
A fix
---
Turning
> storage[length + 1] = '\0';
into
> storage[length] = '\0';
This will ensure that the \0 byte is always written within the |storage| string.
Assignee | ||
Updated•8 years ago
|
Blocks: coverity-analysis
Whiteboard: CID 1402662
Assignee | ||
Comment 1•8 years ago
|
||
Note that this is my first bug report. Please let me know what can be improved.
Assignee | ||
Comment 2•8 years ago
|
||
Also, please add me as assignee for this bug.
Comment hidden (mozreview-request) |
Comment 4•8 years ago
|
||
I think this is a 3rd party library that we are using and the fix should be pushed upstream: https://github.com/kinetiknz/cubeb
Comment 5•8 years ago
|
||
Paul, do you know if this is something we need to push upstream?
Flags: needinfo?(padenot)
Comment 6•8 years ago
|
||
mozreview-review |
Comment on attachment 8850002 [details]
Bug 1349527 - Remove an extra +1 in cubeb_log_message::cubeb_log_message()
https://reviewboard.mozilla.org/r/122758/#review127160
Attachment #8850002 -
Flags: review+
Comment 7•8 years ago
|
||
Thanks for the patch Tristan, we'll get that upstreamed.
Flags: needinfo?(padenot)
Updated•8 years ago
|
Assignee: nobody → tristanbourvon
Comment 8•8 years ago
|
||
Now upstream at https://github.com/kinetiknz/cubeb/commit/192b65548a0402df8f94904f68a191b390beca7f, we'll get that in gecko shortly.
Updated•8 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Updated•8 years ago
|
Rank: 15
Priority: -- → P1
This is an assigned P1 bug without activity in two weeks.
If you intend to continue working on this bug for the current release/iteration/sprint, remove the 'stale-bug' keyword.
Otherwise we'll reset the priority of the bug back to '--' on Monday, August 28th.
Keywords: stale-bug
Comment 10•7 years ago
|
||
Mass change P1->P2 to align with new Mozilla triage process
Priority: P1 → P2
Comment 11•6 years ago
|
||
Moving to p3 because no activity for at least 1 year(s).
See https://github.com/mozilla/bug-handling/blob/master/policy/triage-bugzilla.md#how-do-you-triage for more information
Priority: P2 → P3
Comment 12•3 years ago
|
||
This has been fixed for some time by regular cubeb uplift into Gecko.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•