Skip to content

Commit 4827670

Browse files
aryabiningregkh
authored andcommitted
crypto: x86/sha1-mb - fix panic due to unaligned access
commit d041b557792c85677f17e08eee535eafbd6b9aa2 upstream. struct sha1_ctx_mgr allocated in sha1_mb_mod_init() via kzalloc() and later passed in sha1_mb_flusher_mgr_flush_avx2() function where instructions vmovdqa used to access the struct. vmovdqa requires 16-bytes aligned argument, but nothing guarantees that struct sha1_ctx_mgr will have that alignment. Unaligned vmovdqa will generate GP fault. Fix this by replacing vmovdqa with vmovdqu which doesn't have alignment requirements. Fixes: 2249cbb ("crypto: sha-mb - SHA1 multibuffer submit and flush routines for AVX2") Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 44540ea commit 4827670

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

arch/x86/crypto/sha-mb/sha1_mb_mgr_flush_avx2.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ LABEL skip_ %I
174174
.endr
175175

176176
# Find min length
177-
vmovdqa _lens+0*16(state), %xmm0
178-
vmovdqa _lens+1*16(state), %xmm1
177+
vmovdqu _lens+0*16(state), %xmm0
178+
vmovdqu _lens+1*16(state), %xmm1
179179

180180
vpminud %xmm1, %xmm0, %xmm2 # xmm2 has {D,C,B,A}
181181
vpalignr $8, %xmm2, %xmm3, %xmm3 # xmm3 has {x,x,D,C}
@@ -195,8 +195,8 @@ LABEL skip_ %I
195195
vpsubd %xmm2, %xmm0, %xmm0
196196
vpsubd %xmm2, %xmm1, %xmm1
197197

198-
vmovdqa %xmm0, _lens+0*16(state)
199-
vmovdqa %xmm1, _lens+1*16(state)
198+
vmovdqu %xmm0, _lens+0*16(state)
199+
vmovdqu %xmm1, _lens+1*16(state)
200200

201201
# "state" and "args" are the same address, arg1
202202
# len is arg2
@@ -260,8 +260,8 @@ ENTRY(sha1_mb_mgr_get_comp_job_avx2)
260260
jc .return_null
261261

262262
# Find min length
263-
vmovdqa _lens(state), %xmm0
264-
vmovdqa _lens+1*16(state), %xmm1
263+
vmovdqu _lens(state), %xmm0
264+
vmovdqu _lens+1*16(state), %xmm1
265265

266266
vpminud %xmm1, %xmm0, %xmm2 # xmm2 has {D,C,B,A}
267267
vpalignr $8, %xmm2, %xmm3, %xmm3 # xmm3 has {x,x,D,C}

0 commit comments

Comments
 (0)