From patchwork Tue Oct 3 02:22:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 9981407 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37D0260384 for ; Tue, 3 Oct 2017 02:22:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B7D728A52 for ; Tue, 3 Oct 2017 02:22:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2044728A5C; Tue, 3 Oct 2017 02:22:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCB4128A52 for ; Tue, 3 Oct 2017 02:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751131AbdJCCWV (ORCPT ); Mon, 2 Oct 2017 22:22:21 -0400 Received: from m12-13.163.com ([220.181.12.13]:51626 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750869AbdJCCWU (ORCPT ); Mon, 2 Oct 2017 22:22:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=FaoJNo/ih0/s2zIcJH /t98ULZCx1awQ4MeU8G53p0/I=; b=Zhq4KN3hchDzeazX/hFxtOeg249Cl85Kdk V5vPEiFHDYx0z+fodl+ZIXoYkvJk1qUwiLtxVn7YBzdO7G5ry7zjCIXYK/Svs2uk M5g030UITlNCNuEIm5yLI5ftZyKlOu6/Wg1D8wuacvCDooqL+W+aZWbzRNUGBZrg Kce8EO2Bk= Received: from bai-oslab.tsinghua.edu.cn (unknown [166.111.70.46]) by smtp9 (Coremail) with SMTP id DcCowACXtFXm89JZhQWvLw--.27144S2; Tue, 03 Oct 2017 10:20:25 +0800 (CST) From: Jia-Ju Bai To: davem@davemloft.net, herbert@gondor.apana.org.au, nhorman@tuxdriver.com, vyasevich@gmail.com, luto@kernel.org, kvalo@codeaurora.org Cc: linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-sctp@vger.kernel.org, linux-wireless@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] Fix a sleep-in-atomic bug in shash_setkey_unaligned Date: Tue, 3 Oct 2017 10:22:44 +0800 Message-Id: <1506997364-26541-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DcCowACXtFXm89JZhQWvLw--.27144S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtrW8Cry5AF17Zw4DJw43ZFb_yoWfAFb_GF ykuwn5Wr1jyrs5u397G3ykJrnF9r1fGFy09a4fXr13t345Jr45WFn29r1DZ3Z3Zr43Jr98 Wan5Gr9xJrnF9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbdgA3UUUUU== X-Originating-IP: [166.111.70.46] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiYwlmelaDvGCFfwAAsF Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- crypto/shash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/shash.c b/crypto/shash.c index 5e31c8d..8fcecc6 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -41,7 +41,7 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key, int err; absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); - buffer = kmalloc(absize, GFP_KERNEL); + buffer = kmalloc(absize, GFP_ATOMIC); if (!buffer) return -ENOMEM;