Skip to content

Commit 02caf91

Browse files
Eric Biggersgregkh
authored andcommitted
crypto: x86/aegis - Fix sleeping when disallowed on PREEMPT_RT
commit c7f49da upstream. skcipher_walk_done() can call kfree(), which takes a spinlock, which makes it incorrect to call while preemption is disabled on PREEMPT_RT. Therefore, end the kernel-mode FPU section before calling skcipher_walk_done(), and restart it afterwards. Moreover, pass atomic=false to skcipher_walk_aead_encrypt() instead of atomic=true. The point of atomic=true was to make skcipher_walk_done() safe to call while in a kernel-mode FPU section, but that does not actually work. So just use the usual atomic=false. Fixes: 1d373d4 ("crypto: x86 - Add optimized AEGIS implementations") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e59a52e commit 02caf91

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/crypto/aegis128-aesni-glue.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ crypto_aegis128_aesni_process_crypt(struct aegis_state *state,
119119
walk->dst.virt.addr,
120120
round_down(walk->nbytes,
121121
AEGIS128_BLOCK_SIZE));
122+
kernel_fpu_end();
122123
skcipher_walk_done(walk, walk->nbytes % AEGIS128_BLOCK_SIZE);
124+
kernel_fpu_begin();
123125
}
124126

125127
if (walk->nbytes) {
@@ -131,7 +133,9 @@ crypto_aegis128_aesni_process_crypt(struct aegis_state *state,
131133
aegis128_aesni_dec_tail(state, walk->src.virt.addr,
132134
walk->dst.virt.addr,
133135
walk->nbytes);
136+
kernel_fpu_end();
134137
skcipher_walk_done(walk, 0);
138+
kernel_fpu_begin();
135139
}
136140
}
137141

@@ -176,9 +180,9 @@ crypto_aegis128_aesni_crypt(struct aead_request *req,
176180
struct aegis_state state;
177181

178182
if (enc)
179-
skcipher_walk_aead_encrypt(&walk, req, true);
183+
skcipher_walk_aead_encrypt(&walk, req, false);
180184
else
181-
skcipher_walk_aead_decrypt(&walk, req, true);
185+
skcipher_walk_aead_decrypt(&walk, req, false);
182186

183187
kernel_fpu_begin();
184188

0 commit comments

Comments
 (0)