Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42b1ea8a authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Turn off overflow protection for various math functions

These functions also exist as arm assembly files, where the overflows
just wrap around, and this makes their plain C equivalents behave
the same.

Bug: 32577290
Bug: 33071964
Test: ran PoC for bug 32577290 using plain C source code
Change-Id: I73c2609589e7a89d36f6c44391548312259daf14
(cherry picked from commit cbf5e691)
parent 4f34250a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ extern "C"



    __attribute__((no_sanitize("integer")))
    __inline int32 pv_abs(int32 a)
    {
        int32 b = (a < 0) ? -a : a;
@@ -59,49 +60,58 @@ extern "C"



    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
    {
        return (Int32)(((int64)(a) * b) >> 30);
    }

    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
    {
        return (L_add + (Int32)(((int64)(a) * b) >> 30));
    }

    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b)
    {
        return (Int32)(((int64)(a) * b) >> 32);
    }


    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
    {
        return (Int32)(((int64)(a) * b) >> 28);
    }

    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
    {
        return (Int32)(((int64)(a) * b) >> 27);
    }

    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
    {
        return (Int32)(((int64)(a) * b) >> 26);
    }


    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b)
    {
        return (L_add + (Int32)(((int64)(a) * b) >> 32));
    }

    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b)
    {
        return (L_sub - ((Int32)(((int64)(a) * b) >> 32)));
    }


    __attribute__((no_sanitize("integer")))
    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
    {
        return (Int32)(((int64)(a) * b) >> 29);
+3 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ const int32 CosTable_dct32[16] =
; FUNCTION CODE
----------------------------------------------------------------------------*/

__attribute__((no_sanitize("integer")))
void pvmp3_dct_16(int32 vec[], int32 flag)
{
    int32 tmp0;
@@ -308,6 +309,7 @@ void pvmp3_dct_16(int32 vec[], int32 flag)
/*----------------------------------------------------------------------------
; FUNCTION CODE
----------------------------------------------------------------------------*/
__attribute__((no_sanitize("integer")))
void pvmp3_merge_in_place_N32(int32 vec[])
{

@@ -366,6 +368,7 @@ void pvmp3_merge_in_place_N32(int32 vec[])



__attribute__((no_sanitize("integer")))
void pvmp3_split(int32 *vect)
{

+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ Returns
; FUNCTION CODE
----------------------------------------------------------------------------*/

__attribute__((no_sanitize("integer")))
void pvmp3_dct_9(int32 vec[])
{

+1 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ const int32 cosTerms_1_ov_cos_phi[18] =



__attribute__((no_sanitize("integer")))
void pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window)
{
    int32 i;