Skip to content

Commit 5dfeaac

Browse files
aryabininherbertx
authored andcommitted
crypto: x86/sha256-mb - fix panic due to unaligned access
struct sha256_ctx_mgr allocated in sha256_mb_mod_init() via kzalloc() and later passed in sha256_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 sha256_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: a377c6b ("crypto: sha256-mb - submit/flush routines for AVX2") Reported-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: <stable@vger.kernel.org> Acked-by: Tim Chen Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 4635742 commit 5dfeaac

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ LABEL skip_ %I
155155
.endr
156156

157157
# Find min length
158-
vmovdqa _lens+0*16(state), %xmm0
159-
vmovdqa _lens+1*16(state), %xmm1
158+
vmovdqu _lens+0*16(state), %xmm0
159+
vmovdqu _lens+1*16(state), %xmm1
160160

161161
vpminud %xmm1, %xmm0, %xmm2 # xmm2 has {D,C,B,A}
162162
vpalignr $8, %xmm2, %xmm3, %xmm3 # xmm3 has {x,x,D,C}
@@ -176,8 +176,8 @@ LABEL skip_ %I
176176
vpsubd %xmm2, %xmm0, %xmm0
177177
vpsubd %xmm2, %xmm1, %xmm1
178178

179-
vmovdqa %xmm0, _lens+0*16(state)
180-
vmovdqa %xmm1, _lens+1*16(state)
179+
vmovdqu %xmm0, _lens+0*16(state)
180+
vmovdqu %xmm1, _lens+1*16(state)
181181

182182
# "state" and "args" are the same address, arg1
183183
# len is arg2
@@ -234,8 +234,8 @@ ENTRY(sha256_mb_mgr_get_comp_job_avx2)
234234
jc .return_null
235235

236236
# Find min length
237-
vmovdqa _lens(state), %xmm0
238-
vmovdqa _lens+1*16(state), %xmm1
237+
vmovdqu _lens(state), %xmm0
238+
vmovdqu _lens+1*16(state), %xmm1
239239

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

0 commit comments

Comments
 (0)