Closed Bug 1607588 Opened 4 years ago Closed 2 years ago

ThreadSanitizer: data race [@ nssSlot_GetToken] vs. [@ nssToken_Destroy] with potential use-after-free during shutdown

Categories

(Core :: Security: PSM, defect, P2)

x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: decoder, Unassigned)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [nss-fx][nss-monitor])

Crash Data

Attachments

(5 files)

The attached crash information was detected while running CI tests with ThreadSanitizer on mozilla-central revision bc5880b621d5.

This is a race I saw during the security/manager/ssl/tests/unit/test_nss_shutdown.js test. It looks like a use-after-free on an nssToken. The main thread has ShutdownNSS() on the stack, so I assume this could be a shutdown problem, but it is unclear to me if this is test-only or if the same can happen in production. At most, this could cause intermittent test failures (crashes) of the particular test. And indeed we have bug 1563837 and bug 1546720 on file for intermittent crashes of this particular test.

General information about TSan reports

Why fix races?

Data races are undefined behavior and can cause crashes as well as correctness issues. Compiler optimizations can cause racy code to have unpredictable and hard-to-reproduce behavior.

Rating

If you think this race can cause crashes or correctness issues, it would be great to rate the bug appropriately as P1/P2 and/or indicating this in the bug. This makes it a lot easier for us to assess the actual impact that these reports make and if they are helpful to you.

False Positives / Benign Races

Typically, races reported by TSan are not false positives [1], but it is possible that the race is benign. Even in this case it would be nice to come up with a fix if it is easily doable and does not regress performance. Every race that we cannot fix will have to remain on the suppression list and slows down the overall TSan performance. Also note that seemingly benign races can possibly be harmful (also depending on the compiler, optimizations and the architecture) [2][3].

[1] One major exception is the involvement of uninstrumented code from third-party libraries.
[2] http://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
[3] How to miscompile programs with "benign" data races: https://www.usenix.org/legacy/events/hotpar11/tech/final_files/Boehm.pdf

Suppressing unfixable races

If the bug cannot be fixed, then a runtime suppression needs to be added in mozglue/build/TsanOptions.cpp. The suppressions match on the full stack, so it should be picked such that it is unique to this particular race. The bug number of this bug should also be included so we have some documentation on why this suppression was added.

Assignee: nobody → nobody
Component: Security: PSM → Libraries
Product: Core → NSS
QA Contact: jjones
Version: Trunk → other

I spent some time this morning going through this code comparing to prior notes for NSS shutdown. It's good that we do have finally an exact case of what's happening during this race, but sadly we already knew the final culprits, and the ultimate cause being that NSS is synchronizing the wrong things during slot destruction... which is rough to fix.

I'm marking this P2 because it's worth a few hours searching before we decide P1 or P3.

Priority: -- → P2
Pushed by abeingessner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ac0770d9bdfa
Remove supression for seemingly fixed issue. r=decoder
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Assignee: nobody → a.beingessner
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee: a.beingessner → nobody
Pushed by abeingessner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e17a24cf19c8
add back supression for code that gets stressed more in a full shutdown. r=decoder
Whiteboard: [nss-fx]

The leave-open keyword is there and there is no activity for 6 months.
:beurdouche, maybe it's time to close this bug?

Flags: needinfo?(bbeurdouche)
Flags: needinfo?(bbeurdouche)
Whiteboard: [nss-fx] → [nss-fx][nss-monitor]

The leave-open keyword is there and there is no activity for 6 months.
:beurdouche, maybe it's time to close this bug?

Flags: needinfo?(bbeurdouche)
Flags: needinfo?(bbeurdouche)
Keywords: leave-open
Depends on: 1756271
Pushed by jschanck@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/51dfe326a194
Remove suppression for NSS shutdown race. r=decoder
Status: REOPENED → RESOLVED
Closed: 4 years ago2 years ago
Resolution: --- → FIXED
No longer blocks: 1563837
Assignee: nobody → nobody
Component: Libraries → Security: PSM
Product: NSS → Core
Target Milestone: --- → 100 Branch
Version: other → unspecified
No longer blocks: 1546720
Depends on: 1546720
Blocks: 1763237
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: