This is an archive of the discontinued LLVM Phabricator instance.

[ASan] Add interceptros for fortified strcat, strncat, strcpy, strncpy.
AbandonedPublic

Authored by denis13 on Dec 14 2017, 8:03 AM.

Details

Summary

There might be a situation when asan-ed binary links against DSO which were built with FORTIFY_SOURCE option, in case DSO has strcat, strncat, strcpy or strncpy functions, ASan should has interceptors for the "fortified" functions to be able to handle potential memory bugs.

GCC and clang produces different code with this functions:
in case compiler is gcc, it replaces strcat, strncat, strcpy or strncpy to "fortifed" functions, but clang generates code which does not have this functions at all.
So, to be able to test the interceptors, I've manually added strcat_chk, strncat_chk, strcpy_chk, strncpy_chk functions to the tests.

Diff Detail

Event Timeline

denis13 created this revision.Dec 14 2017, 8:03 AM
kcc added a comment.Dec 19 2017, 10:52 AM

The discussion about asan+fortify has been going on for ages and I don't think we ever reached an agreement on how to proceed. Did we?

vitalybuka added inline comments.Dec 19 2017, 10:56 AM
lib/asan/asan_interceptors.cc
359

Interceptor should use to_size.

363

Look like all implementations are copy/paste from non _chk code. We need to extract and share common parts.

kcc added a comment.Dec 19 2017, 11:15 AM

I suggest to restart the discussion of this topic with the owners of fortify.
So far I am not convinced that we need/want this code in asan.

vitalybuka resigned from this revision.Jan 19 2018, 12:04 PM
denis13 abandoned this revision.Jan 16 2020, 8:16 AM