This is an archive of the discontinued LLVM Phabricator instance.

[asan] Add options -asan-detect-invalid-pointer-cmp and -asan-detect-invalid-pointer-sub options.
ClosedPublic

Authored by pgousseau on Mar 11 2019, 10:07 AM.

Details

Summary

This is in preparation to a driver patch to add gcc 8's -fsanitize=pointer-compare and -fsanitize=pointer-subtract.
Disabled by default as this is still an experimental feature.
This is the llvm side of https://reviews.llvm.org/D59221

Diff Detail

Repository
rL LLVM

Event Timeline

pgousseau created this revision.Mar 11 2019, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2019, 10:07 AM
pgousseau edited the summary of this revision. (Show Details)Mar 11 2019, 10:13 AM
pgousseau added a reviewer: gbedwell.
ormris added a subscriber: ormris.Mar 12 2019, 9:59 AM
ormris removed a subscriber: ormris.Mar 26 2019, 9:20 AM
morehouse added inline comments.Mar 26 2019, 9:36 AM
lib/Transforms/Instrumentation/AddressSanitizer.cpp
575 ↗(On Diff #190117)

These parameter lists are getting too long. Do we need to store the options or can we just check ClInvalidPointer* instead? Or, can we use an options struct?

test/Instrumentation/AddressSanitizer/asan-detect-invalid-pointer-pair.ll
2 ↗(On Diff #190117)

I think we can do --check-prefixes=CMP,NOSUB.

12 ↗(On Diff #190117)

Do we also need to add --check-prefix=ALL?

What is exactly going to be checked by -fsanitize=pointer-compare and -fsanitize=pointer-subtract?
Why this needs to be done in AddressSanitizer?
Is this going just checheck that pointers are from the same allocation?

pgousseau updated this revision to Diff 192445.Mar 27 2019, 8:09 AM

Use backend option directly rather than introducing new parameters.
Add missing ALL check to test.

pgousseau marked 4 inline comments as done.Mar 27 2019, 8:10 AM
pgousseau added inline comments.
lib/Transforms/Instrumentation/AddressSanitizer.cpp
575 ↗(On Diff #190117)

Yes the parameter are not necessary, I have removed them thanks!

pgousseau marked an inline comment as done.Mar 27 2019, 8:11 AM

What is exactly going to be checked by -fsanitize=pointer-compare and -fsanitize=pointer-subtract?
Why this needs to be done in AddressSanitizer?
Is this going just checheck that pointers are from the same allocation?

-fsanitize=pointer-compare and -fsanitize=pointer-subtract instrument comparison operation (<, <=, >, >=) and '-' operation with pointer operands.
It relies on AddressSanitizer to check the origin of the allocation. gcc also requires -fsanitize=address for -fsanitize=pointer-compare and -fsanitize=pointer-subtract, so I think it is expected to depend on Asan? Thanks!

morehouse accepted this revision.Mar 27 2019, 10:19 AM
morehouse added inline comments.
test/Instrumentation/AddressSanitizer/asan-detect-invalid-pointer-pair.ll
2 ↗(On Diff #190117)

Well now we can just do --check-prefixes=CMP,NOSUB,ALL

This revision is now accepted and ready to land.Mar 27 2019, 10:19 AM
pgousseau marked 2 inline comments as done.Mar 28 2019, 3:51 AM
pgousseau added inline comments.
test/Instrumentation/AddressSanitizer/asan-detect-invalid-pointer-pair.ll
2 ↗(On Diff #190117)

Done thanks!

This revision was automatically updated to reflect the committed changes.
pgousseau marked an inline comment as done.