Skip to content

Commit 9039f3e

Browse files
XidianGeneralherbertx
authored andcommitted
crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned
The SCTP program may sleep under a spinlock, and the function call path is: sctp_generate_t3_rtx_event (acquire the spinlock) sctp_do_sm sctp_side_effects sctp_cmd_interpreter sctp_make_init_ack sctp_pack_cookie crypto_shash_setkey shash_setkey_unaligned kmalloc(GFP_KERNEL) For the same reason, the orinoco driver may sleep in interrupt handler, and the function call path is: orinoco_rx_isr_tasklet orinoco_rx orinoco_mic crypto_shash_setkey shash_setkey_unaligned kmalloc(GFP_KERNEL) To fix it, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool and my code review. Signed-off-by: Jia-Ju Bai <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 5125e4e commit 9039f3e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crypto/shash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
4141
int err;
4242

4343
absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
44-
buffer = kmalloc(absize, GFP_KERNEL);
44+
buffer = kmalloc(absize, GFP_ATOMIC);
4545
if (!buffer)
4646
return -ENOMEM;
4747

0 commit comments

Comments
 (0)