This is an archive of the discontinued LLVM Phabricator instance.

[asan] Fix bug where suppression of overlapping accesses was ignored.
ClosedPublic

Authored by delcypher on Feb 23 2018, 4:14 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

delcypher created this revision.Feb 23 2018, 4:14 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptFeb 23 2018, 4:14 PM
kubamracek added inline comments.Feb 26 2018, 9:58 AM
lib/asan/asan_interceptors_memintrinsics.h
144 ↗(On Diff #135727)

Can we also check for suppressions based on interceptor name? See ACCESS_MEMORY_RANGE above, which is attempting suppressions both by name and by stacktrace.

test/asan/TestCases/strncpy-overlap.cc
29 ↗(On Diff #135727)

Since the "Linux" line is matching the Darwin output as well, can we just use the Linux version?

delcypher added inline comments.Feb 26 2018, 10:48 AM
lib/asan/asan_interceptors_memintrinsics.h
144 ↗(On Diff #135727)

ACCESS_MEMORY_RANGE has access to a ctx object. Where do I get that from?

test/asan/TestCases/strncpy-overlap.cc
29 ↗(On Diff #135727)

We could do. I think I copied the regex from the existing in strncpy-overflow.cc test. Is that test a bad example of how to do things?

kubamracek added inline comments.Feb 26 2018, 10:56 AM
lib/asan/asan_interceptors_memintrinsics.h
144 ↗(On Diff #135727)

I think we can pass ctx from the caller(s), all the callers already seem to have it. Or we can use name directly here, but actually removing it in favor of ctx sounds better to me.

test/asan/TestCases/strncpy-overlap.cc
29 ↗(On Diff #135727)

It's not a big deal, but it just seems unnecessary to complicate this test with OS specific checks.

kubamracek added inline comments.Feb 26 2018, 10:57 AM
test/asan/TestCases/strncpy-overlap.cc
29 ↗(On Diff #135727)

Thinking more about it, I don't see a good reason why the two OS's should differ in behavior here anyway. At some point, we should probably stop printing the "wrap_" prefix on Darwin (it's just a side effect of how interceptors work on Darwin).

delcypher updated this revision to Diff 137440.Mar 7 2018, 11:09 AM

Support interceptor_name suppression.

delcypher marked 5 inline comments as done.Mar 7 2018, 11:12 AM
delcypher added inline comments.
lib/asan/asan_interceptors_memintrinsics.h
144 ↗(On Diff #135727)

I've added support for doing the suppression by interceptor name. However I've not made the ctx change. That looks like an orthogonal refactor which I do in a separate patch.

kubamracek accepted this revision.Mar 7 2018, 11:20 AM

LGTM, thanks!

This revision is now accepted and ready to land.Mar 7 2018, 11:20 AM
delcypher updated this revision to Diff 137584.Mar 8 2018, 8:46 AM
delcypher marked an inline comment as done.
delcypher edited the summary of this revision. (Show Details)

Add tests for strcat(), strncat(), and strcpy().

LGTM, thanks!

I decided that I should probably add tests for the other functions where we do this overlap check. Could you check you're still happy with this patch?

Sidenote: It looks like we are missing interceptors for

  • stpcpy()
  • strlcpy()
  • strlcat()

Fixing that is out of scope for this patch though.

Looks great. Thanks!

alekseyshl added inline comments.Mar 8 2018, 10:35 AM
test/asan/TestCases/strncpy-overlap.cc
23 ↗(On Diff #137584)

--check-prefix=CHECK is the default, let's just drop it

delcypher updated this revision to Diff 137625.Mar 8 2018, 11:39 AM

Remove superflous --check-prefix command line option.

delcypher marked an inline comment as done.Mar 8 2018, 11:40 AM

@alekseyshl Good to go?

test/asan/TestCases/strncpy-overlap.cc
23 ↗(On Diff #137584)

Oops. Good catch. I forgot to remove those after re-working the tests.

alekseyshl accepted this revision.Mar 8 2018, 1:11 PM
This revision was automatically updated to reflect the committed changes.
delcypher marked an inline comment as done.