From abd80d3c5a0ae68cf0ded6c3262a559ee330c01f Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Fri, 15 Dec 2023 15:18:33 +0000 Subject: [PATCH] erasure_code: check for size in gf_Xvect_mad_avx512_gfni Length of data was not checked in implementation with AVX512+GFNI, at the start of the gf_Xvect_mad_avx512_gfni functions, resulting in buffer overflow if length was less than 64 bytes. Signed-off-by: Pablo de Lara --- erasure_code/gf_2vect_mad_avx512_gfni.asm | 2 ++ erasure_code/gf_3vect_mad_avx512_gfni.asm | 2 ++ erasure_code/gf_4vect_mad_avx512_gfni.asm | 2 ++ erasure_code/gf_5vect_mad_avx512_gfni.asm | 2 ++ erasure_code/gf_6vect_mad_avx512_gfni.asm | 2 ++ erasure_code/gf_vect_mad_avx512_gfni.asm | 2 ++ 6 files changed, 12 insertions(+) diff --git a/erasure_code/gf_2vect_mad_avx512_gfni.asm b/erasure_code/gf_2vect_mad_avx512_gfni.asm index a50385f..fba32ae 100644 --- a/erasure_code/gf_2vect_mad_avx512_gfni.asm +++ b/erasure_code/gf_2vect_mad_avx512_gfni.asm @@ -158,6 +158,8 @@ func(gf_2vect_mad_avx512_gfni) mov dest2, [dest1 + 8] ; reuse mul_array mov dest1, [dest1] + cmp len, 64 + jl .len_lt_64 .loop64: ENCODE_64B_2 diff --git a/erasure_code/gf_3vect_mad_avx512_gfni.asm b/erasure_code/gf_3vect_mad_avx512_gfni.asm index 3794c0b..6fc02e9 100644 --- a/erasure_code/gf_3vect_mad_avx512_gfni.asm +++ b/erasure_code/gf_3vect_mad_avx512_gfni.asm @@ -173,6 +173,8 @@ func(gf_3vect_mad_avx512_gfni) mov dest3, [dest1 + 2*8] ; reuse vec mov dest1, [dest1] + cmp len, 64 + jl .len_lt_64 .loop64: ENCODE_64B_3 diff --git a/erasure_code/gf_4vect_mad_avx512_gfni.asm b/erasure_code/gf_4vect_mad_avx512_gfni.asm index 547ee90..eac36da 100644 --- a/erasure_code/gf_4vect_mad_avx512_gfni.asm +++ b/erasure_code/gf_4vect_mad_avx512_gfni.asm @@ -192,6 +192,8 @@ func(gf_4vect_mad_avx512_gfni) mov dest4, [dest1 + 3*8] ; reuse vec_i mov dest1, [dest1] + cmp len, 64 + jl .len_lt_64 .loop64: ENCODE_64B_4 diff --git a/erasure_code/gf_5vect_mad_avx512_gfni.asm b/erasure_code/gf_5vect_mad_avx512_gfni.asm index 018e8ac..826e7dd 100644 --- a/erasure_code/gf_5vect_mad_avx512_gfni.asm +++ b/erasure_code/gf_5vect_mad_avx512_gfni.asm @@ -209,6 +209,8 @@ func(gf_5vect_mad_avx512_gfni) mov dest5, [dest1 + 4*8] ; reuse vec_i mov dest1, [dest1] + cmp len, 64 + jl .len_lt_64 .loop64: ENCODE_64B_5 diff --git a/erasure_code/gf_6vect_mad_avx512_gfni.asm b/erasure_code/gf_6vect_mad_avx512_gfni.asm index 5539e23..97698d1 100644 --- a/erasure_code/gf_6vect_mad_avx512_gfni.asm +++ b/erasure_code/gf_6vect_mad_avx512_gfni.asm @@ -228,6 +228,8 @@ func(gf_6vect_mad_avx512_gfni) mov dest6, [dest1 + 5*8] ; reuse vec_i mov dest1, [dest1] + cmp len, 64 + jl .len_lt_64 .loop64: ENCODE_64B_6 diff --git a/erasure_code/gf_vect_mad_avx512_gfni.asm b/erasure_code/gf_vect_mad_avx512_gfni.asm index 12a104a..ce3b42e 100644 --- a/erasure_code/gf_vect_mad_avx512_gfni.asm +++ b/erasure_code/gf_vect_mad_avx512_gfni.asm @@ -144,6 +144,8 @@ func(gf_vect_mad_avx512_gfni) vbroadcastf32x2 xgft1, [vec_i + mul_array] + cmp len, 64 + jl .len_lt_64 .loop64: ENCODE_64B