This is an archive of the discontinued LLVM Phabricator instance.

[GWP-ASan] Add inbuilt options parser.
ClosedPublic

Authored by hctim on Dec 4 2020, 3:00 PM.

Details

Summary

Adds a modified options parser (shamefully pulled from Scudo, which
shamefully pulled it from sanitizer-common) to GWP-ASan. This allows
customers (Android) to parse options strings in a common way.

Depends on D94117.

AOSP side of these patches is staged at:

Diff Detail

Event Timeline

hctim created this revision.Dec 4 2020, 3:00 PM
hctim requested review of this revision.Dec 4 2020, 3:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2020, 3:00 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
eugenis added a subscriber: eugenis.Dec 4 2020, 3:16 PM

It is probably a good idea to fuzz the option parser before using it in prod.

hctim planned changes to this revision.Dec 7 2020, 10:06 AM

(WIP)

hctim removed a project: Restricted Project.Jan 5 2021, 12:06 PM
hctim removed subscribers: eugenis, mgorny, cryptoad, Restricted Project.
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2021, 12:06 PM
hctim updated this revision to Diff 314685.Jan 5 2021, 12:09 PM

(full cmake patches, basis for working backwards).

hctim updated this revision to Diff 314686.Jan 5 2021, 12:10 PM
  • add the options parser.
hctim updated this revision to Diff 314729.Jan 5 2021, 2:59 PM

(rebased, depends on D94117)

hctim updated this revision to Diff 314731.Jan 5 2021, 3:29 PM
  • Add options parser fuzzer. Run pretty extensively under ASan without problems.
hctim updated this revision to Diff 314752.Jan 5 2021, 4:38 PM
  • Add very large warning about flags.
hctim edited the summary of this revision. (Show Details)Jan 5 2021, 4:41 PM
hctim added reviewers: eugenis, cferris, cryptoad.
hctim added a subscriber: enh.
eugenis added inline comments.Jan 11 2021, 3:31 PM
compiler-rt/lib/gwp_asan/optional/options_parser.cpp
66

why is UnknownOptionsRegistry necessary? just print them as you find them

120

check that numberofoptions < maxoptions just in case

163

This is only needed to implement "include=" flag, we should not have those in gwp-asan.

hctim updated this revision to Diff 316769.Jan 14 2021, 1:32 PM
hctim marked 3 inline comments as done.
  • Addressed eugenis@'s comments, delete unknown registry and remove some unnecessary code.
This revision is now accepted and ready to land.Jan 15 2021, 12:15 PM
This revision was landed with ongoing or failed builds.Jan 15 2021, 1:17 PM
This revision was automatically updated to reflect the committed changes.
mcgrathr added inline comments.
compiler-rt/lib/gwp_asan/optional/options_parser.h
14

This dependency on sanitizer_common breaks gwp_asan integration into scudo/standalone as used on Fuchsia, where sanitizer_common is not available (and not desired).

hctim marked an inline comment as done.Jan 26 2021, 11:41 AM
hctim added inline comments.
compiler-rt/lib/gwp_asan/optional/options_parser.h
14

The options parser is an optional component (i.e. a plugin). Previously, this plugin used the sanitizer_common codebase. Now, it is entirely standalone.

Prior to this patch, Scudo used its own flag parser (e.g. SCUDO_OPTIONS=GWP_ASAN_SampleRate=1337) and didn't use the plugin. After this patch, Scudo uses the plugin (GWP_ASAN_OPTIONS=SampleRate=1337).

GWP-ASan needs a standalone flag parser for Android, where Scudo and GWP-ASan are decoupled. With respect to Scudo, I'm happy for it to either use the plugin or not - doesn't bother me :).

cryptoad added inline comments.Jan 26 2021, 2:01 PM
compiler-rt/lib/gwp_asan/optional/options_parser.h
14

I can "revert" the changes applied to the Scudo side to keep the existing parsing.

hctim marked 2 inline comments as done.Jan 26 2021, 2:23 PM
hctim added inline comments.
compiler-rt/lib/gwp_asan/optional/options_parser.h
14

If that's what you'd like on the Scudo side, please feel free :).