Closed Bug 1919290 Opened 2 months ago Closed 1 month ago

Multiple ASAN failure reports in comm/mailnews/mime (mimeenc.cpp:162:12, mimeenc.cpp:287:12, mimeenc.cpp:489:18, mimepbuf.cpp:207:14)

Categories

(MailNews Core :: MIME, defect)

Thunderbird 132
defect

Tracking

(thunderbird_esr128 affected, thunderbird132 fixed)

RESOLVED FIXED
133 Branch
Tracking Status
thunderbird_esr128 --- affected
thunderbird132 --- fixed

People

(Reporter: KaiE, Assigned: KaiE)

References

Details

(Whiteboard: [When backporting to 128 include bug 1927290])

Attachments

(5 files)

After fixing bug 1852662, the ASAN UndefinedBehaviorSanitizer reports multiple additional failures.

The root cause of these issues is:
Our MIME C code uses an untyped void* in various places, but some functions use an explicit typed parameter.

We could potentially fix this new ASAN warning simply by changing those functions to also take a void* paramter, and do an optimistic type cast.

But I think this is against the idea of these checks. We shouldn't fix type checking by forcing parameters to be untyped, and then perform risky downcasting.

My suggestion is that we change the void* for all the "closure" parameters to a lightweight wrapper type, which can be passed around as a parameter (without requiring allocation).

The wrapper should transport which type of parameter we're transporting. That allows our casting functions to perform a check for the expected type, and safely abort on failure (instead of potentially crashing).

Assignee: nobody → kaie
Status: NEW → ASSIGNED
Attachment #9425307 - Attachment description: Bug 1919290 - Type checking for closure parameters in C MIME code. r=BenC → WIP: Bug 1919290 - Type checking for closure parameters in C MIME code.
Attachment #9425307 - Attachment description: WIP: Bug 1919290 - Type checking for closure parameters in C MIME code. → Bug 1919290 - Type checking for closure parameters in C MIME code. r=BenC
Attachment #9425307 - Attachment description: Bug 1919290 - Type checking for closure parameters in C MIME code. r=BenC → WIP: Bug 1919290 - Type checking for closure parameters in C MIME code.
Attachment #9425307 - Attachment description: WIP: Bug 1919290 - Type checking for closure parameters in C MIME code. → Bug 1919290 - Type checking for closure parameters in C MIME code. r=BenC
Summary: Multiple ASAN failure reports in comm/mailnews/mime → Multiple ASAN failure reports in comm/mailnews/mime (mimeenc.cpp:162:12, mimeenc.cpp:287:12, mimeenc.cpp:489:18, mimepbuf.cpp:207:14)
Attachment #9425307 - Attachment description: Bug 1919290 - Type checking for closure parameters in C MIME code. r=BenC → Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=BenC

Will this also impact 128?

Flags: needinfo?(kaie)
Version: unspecified → Thunderbird 132

Yes, I think we should uplift these fixes to 128.

Flags: needinfo?(kaie)
Attachment #9425307 - Attachment description: Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=BenC → Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=#thunderbird-reviewers
Attachment #9426423 - Attachment description: Bug 1919290 - Type checking for data_object in C MIME code. r=BenC → Bug 1919290 - Type checking for data_object in C MIME code. r=#thunderbird-reviewers
Attachment #9426424 - Attachment description: Bug 1919290 - Type checking for output and image closure parameters in C MIME code. r=BenC → Bug 1919290 - Type checking for output and image closure parameters in C MIME code. r=#thunderbird-reviewers
Attachment #9425307 - Attachment description: Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=#thunderbird-reviewers → Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=mkmelin
Attachment #9426423 - Attachment description: Bug 1919290 - Type checking for data_object in C MIME code. r=#thunderbird-reviewers → Bug 1919290 - Type checking for data_object in C MIME code. r=BenC
Attachment #9426424 - Attachment description: Bug 1919290 - Type checking for output and image closure parameters in C MIME code. r=#thunderbird-reviewers → Bug 1919290 - Type checking for output and image closure parameters in C MIME code. r=mkmelin

The patch here depends on the following two commits from bug 1915397,
if you don't apply them (on esr128), you get merge issues.

https://hg.mozilla.org/comm-central/rev/c306f1b7067d
https://hg.mozilla.org/comm-central/rev/306a51c14688

Pushed by kaie@kuix.de:
https://hg.mozilla.org/comm-central/rev/a9a403a53dcc
Type checking for an initial set of closure parameters in C MIME code. r=mkmelin
https://hg.mozilla.org/comm-central/rev/3fdd12e6840c
Type checking for data_object in C MIME code. r=BenC
https://hg.mozilla.org/comm-central/rev/2f426872727b
Type checking for output and image closure parameters in C MIME code. r=mkmelin
https://hg.mozilla.org/comm-central/rev/b492a2fe9f56
Use smarter logic to avoid code repetition. r=BenC

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 133 Branch

Comment on attachment 9425307 [details]
Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=mkmelin

[Approval Request Comment]
Regression caused by (bug #): no
User impact if declined: these patches improve correctness and could potentially reduce risk for crashes
Testing completed (on c-c, etc.): should have no functional changes for the user
Risk to taking this patch (and alternatives if risky): small risk for accidental change in behavior of processing messages

Attachment #9425307 - Flags: approval-comm-esr128?
Attachment #9425307 - Flags: approval-comm-beta?
Attachment #9426423 - Flags: approval-comm-esr128?
Attachment #9426423 - Flags: approval-comm-beta?
Attachment #9426424 - Flags: approval-comm-esr128?
Attachment #9426424 - Flags: approval-comm-beta?
Attachment #9428172 - Flags: approval-comm-esr128?
Attachment #9428172 - Flags: approval-comm-beta?

Note that the 4th patch undoes some of the earlier changes, and modifies them to shorter code. I will attach a patch FYI, that shows that the change is smaller.

Comment on attachment 9425307 [details]
Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=mkmelin

Let's wait a little longer with 128. I realize we'll also need bug 1852662, which got a follow-up bug 1921950, which I'd like to investigate first.

Attachment #9425307 - Flags: approval-comm-esr128?
Attachment #9426423 - Flags: approval-comm-esr128?
Attachment #9426424 - Flags: approval-comm-esr128?
Attachment #9428172 - Flags: approval-comm-esr128?

Comment on attachment 9425307 [details]
Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=mkmelin

[Triage Comment]
Approved for beta
There are 4 patches in total

Attachment #9425307 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9426423 [details]
Bug 1919290 - Type checking for data_object in C MIME code. r=BenC

[Triage Comment]
Approved for beta

Attachment #9426423 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9426424 [details]
Bug 1919290 - Type checking for output and image closure parameters in C MIME code. r=mkmelin

[Triage Comment]
Approved for beta

Attachment #9426424 - Flags: approval-comm-beta? → approval-comm-beta+

Comment on attachment 9428172 [details]
Bug 1919290 - Use smarter logic to avoid code repetition. r=BenC

[Triage Comment]
Approved for beta

Attachment #9428172 - Flags: approval-comm-beta? → approval-comm-beta+
Whiteboard: Thunderbird 132.0b2:

Comment on attachment 9425307 [details]
Bug 1919290 - Type checking for an initial set of closure parameters in C MIME code. r=mkmelin

[Approval Request Comment]
see comment 9

Attachment #9425307 - Flags: approval-comm-esr128?
Attachment #9426423 - Flags: approval-comm-esr128?
Attachment #9426424 - Flags: approval-comm-esr128?
Attachment #9428172 - Flags: approval-comm-esr128?

Given the size of this bug and related bug 1919290, you could consider postponing to a 128.4.1 release (not 128.4.0).

All 4 patches applies cleanly on comm-esr128 for me, please ping me if you have any merge issues, and I'll upload mine.

Let's postpone until we have more clarify around 1925085, there are some overlaps in patches, let's avoid merging trouble for now.

Regressions: 1927290
Whiteboard: [When backporting to 128 include bug 1927290]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: