Skip to content

Improve ASan & HWASan handling of pre-split coroutines to disable stack UAR instrumentation #154830

@rnk

Description

@rnk

ASan & HWASan instrumentation passes both contain logic to move all static allocas over to a dynamically allocated stack frame which can be used to support stack use-after-return detection. In the entry block, it introduces a runtime check if/else pattern to select between dynamically allocated stack memory and heap allocated memory when UAR detection is enabled.

This conflicts with the CoroSplit pass logic, which emits a fatal error for dynamic allocas, which would have to be heap allocated (i.e. rewrite to malloc) to live across suspend points.

There's something obvious here: The passes are both fundamentally doing the same thing. They are moving all stack allocations to the heap.

Normally the pass sequence is corosplit, then sanitizer instruentation. However, to be resilient to odd pass reorderings, it would be better if sanitizer passes simply didn't do UAR detection on pre-split coroutines. This eliminates the pass ordering requirement completely.

Right now, ASan is blind to bugs in coroutine functions in LTO configurations, because we just skip instrumenting pre-split coroutines. Fixing this would improve its defect detection capability.

References:

cc @thurstond @vitalybuka

One thing I'm not clear on is whether we can retain redzone poisoning in all coro / sanitizer pass sequencings.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions