crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned
authorJia-Ju Bai <baijiaju1990@163.com>
Tue, 3 Oct 2017 02:25:22 +0000 (10:25 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 7 Oct 2017 04:04:32 +0000 (12:04 +0800)
commit9039f3ef446e9ffa200200c934f049add9e58426
tree43f987e78052880c69f8e7f2b93fcf3dfafc8fd7
parent5125e4e867ab888f2d4b443a1ce463adefb370db
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 <baijiaju1990@163.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/shash.c