diff options
author | Vishwath Mohan <vishwath@google.com> | 2017-03-23 23:14:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-03-23 23:14:48 +0000 |
commit | c94c4d269a2eed12a64f7f8f30e9f014690a1208 (patch) | |
tree | 9f55e18a16f2dc0e86c08996fee1c8602531f6b4 /libutils | |
parent | 577ba978564549bcfac6c10095a69d9794e299b8 (diff) | |
parent | 27a7aa0f59cc1af578eecb5565504b341363b8b9 (diff) | |
download | core-c94c4d269a2eed12a64f7f8f30e9f014690a1208.tar.gz core-c94c4d269a2eed12a64f7f8f30e9f014690a1208.tar.bz2 core-c94c4d269a2eed12a64f7f8f30e9f014690a1208.zip |
Merge "Blacklist some vector functions for CFI."
Diffstat (limited to 'libutils')
-rw-r--r-- | libutils/include/utils/SortedVector.h | 10 | ||||
-rw-r--r-- | libutils/include/utils/Vector.h | 24 |
2 files changed, 24 insertions, 10 deletions
diff --git a/libutils/include/utils/SortedVector.h b/libutils/include/utils/SortedVector.h index d57465d33..5b2a23200 100644 --- a/libutils/include/utils/SortedVector.h +++ b/libutils/include/utils/SortedVector.h @@ -252,7 +252,7 @@ ssize_t SortedVector<TYPE>::removeItemsAt(size_t index, size_t count) { // --------------------------------------------------------------------------- template<class TYPE> -void SortedVector<TYPE>::do_construct(void* storage, size_t num) const { +UTILS_VECTOR_NO_CFI void SortedVector<TYPE>::do_construct(void* storage, size_t num) const { construct_type( reinterpret_cast<TYPE*>(storage), num ); } @@ -262,22 +262,22 @@ void SortedVector<TYPE>::do_destroy(void* storage, size_t num) const { } template<class TYPE> -void SortedVector<TYPE>::do_copy(void* dest, const void* from, size_t num) const { +UTILS_VECTOR_NO_CFI void SortedVector<TYPE>::do_copy(void* dest, const void* from, size_t num) const { copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); } template<class TYPE> -void SortedVector<TYPE>::do_splat(void* dest, const void* item, size_t num) const { +UTILS_VECTOR_NO_CFI void SortedVector<TYPE>::do_splat(void* dest, const void* item, size_t num) const { splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num ); } template<class TYPE> -void SortedVector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const { +UTILS_VECTOR_NO_CFI void SortedVector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const { move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); } template<class TYPE> -void SortedVector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const { +UTILS_VECTOR_NO_CFI void SortedVector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const { move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); } diff --git a/libutils/include/utils/Vector.h b/libutils/include/utils/Vector.h index 3189fd623..7e00123f7 100644 --- a/libutils/include/utils/Vector.h +++ b/libutils/include/utils/Vector.h @@ -24,6 +24,20 @@ #include <utils/TypeHelpers.h> #include <utils/VectorImpl.h> +/* + * Used to blacklist some functions from CFI. + * + */ +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif + +#if __has_attribute(no_sanitize) +#define UTILS_VECTOR_NO_CFI __attribute__((no_sanitize("cfi"))) +#else +#define UTILS_VECTOR_NO_CFI +#endif + // --------------------------------------------------------------------------- namespace android { @@ -380,7 +394,7 @@ status_t Vector<TYPE>::sort(Vector<TYPE>::compar_r_t cmp, void* state) { // --------------------------------------------------------------------------- template<class TYPE> -void Vector<TYPE>::do_construct(void* storage, size_t num) const { +UTILS_VECTOR_NO_CFI void Vector<TYPE>::do_construct(void* storage, size_t num) const { construct_type( reinterpret_cast<TYPE*>(storage), num ); } @@ -390,22 +404,22 @@ void Vector<TYPE>::do_destroy(void* storage, size_t num) const { } template<class TYPE> -void Vector<TYPE>::do_copy(void* dest, const void* from, size_t num) const { +UTILS_VECTOR_NO_CFI void Vector<TYPE>::do_copy(void* dest, const void* from, size_t num) const { copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); } template<class TYPE> -void Vector<TYPE>::do_splat(void* dest, const void* item, size_t num) const { +UTILS_VECTOR_NO_CFI void Vector<TYPE>::do_splat(void* dest, const void* item, size_t num) const { splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num ); } template<class TYPE> -void Vector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const { +UTILS_VECTOR_NO_CFI void Vector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const { move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); } template<class TYPE> -void Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const { +UTILS_VECTOR_NO_CFI void Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const { move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); } |