disable CFI on some stagefright_foundation internals

The internals of AData do exactly the type casting that upsets CFI
sanitizers, so disable CFI for those routines.

Bug: 153739236
Test: atest sf_foundation_test
Change-Id: I69ac7f064a8d3c874d7587598b450af657c4ba59
gugelfrei
Ray Essick 4 years ago
parent 433ccf7dca
commit 57640b83e4

@ -28,6 +28,10 @@
#undef HIDE
#define HIDE __attribute__((visibility("hidden")))
// The internals of AUnion cause problems with CFI
#undef NO_CFI
#define NO_CFI __attribute__((no_sanitize("cfi")))
namespace android {
/**
@ -93,7 +97,7 @@ struct HIDE _AUnion_impl {
* \param args arbitrary arguments for constructor
*/
template<typename T, typename ...Args>
inline static void emplace(size_t totalSize, T *addr, Args&&... args) {
inline static void NO_CFI emplace(size_t totalSize, T *addr, Args&&... args) {
new(addr)T(std::forward<Args>(args)...);
// clear slack space - this is not technically required
constexpr size_t size = sizeof(T);
@ -160,7 +164,7 @@ public:
template<
typename T, typename ...Args,
typename=typename std::enable_if<is_one_of<T, void, Ts...>::value>::type>
inline void emplace(Args&&... args) {
inline void NO_CFI emplace(Args&&... args) {
_AUnion_impl::emplace(
sizeof(_type), reinterpret_cast<T*>(&mValue), std::forward<Args>(args)...);
}

Loading…
Cancel
Save