From patchwork Fri Jun 8 07:41:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10453933 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 52F3A60234 for ; Fri, 8 Jun 2018 07:42:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 420A9295A0 for ; Fri, 8 Jun 2018 07:42:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36A36295A9; Fri, 8 Jun 2018 07:42:28 +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=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC3FD295A0 for ; Fri, 8 Jun 2018 07:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=73c82IBhTxjHqD9CGv0t1+1FmImxhp+W9XZ9evXSVtY=; b=CbX P9dE4W31oXY9IGg1o8NWP0jENjACGQLHeA2BGMAleJPORu3U2AwKIay/u3I0TpPYmlGmjhNFl1qxj nQcasr7vpWl7HnfCMnMO2hu8T+ZCdGNWTRbMOoLBNhzqVjy/TcAdMjSAx2WdEFqVLZvNfSVatIhkc WibOepD+c+Qof8qt+beMh9Khh72IamjFJbG01bx8LXoB55tv2WMvbIgoUKd6mludo2RCDxfYtTjM0 NVcN/LDZVjShey43FG1eIzbl/RHWWYhJw8uNyoi2reuDdFAWgMCjd9XDPDXhuYfTxoIEWurei4T9H IaJu5mPUrRcfcdp7ovtsEoJRnp3F1XQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fRC2G-0005hT-5n; Fri, 08 Jun 2018 07:42:12 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fRC2C-0005aE-9t for linux-arm-kernel@lists.infradead.org; Fri, 08 Jun 2018 07:42:10 +0000 Received: by mail-pf0-x242.google.com with SMTP id a11-v6so6208753pff.8 for ; Fri, 08 Jun 2018 00:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xDOsFM1m8LjIPXzr05DKGgzHN2YIgV5IvXvx/lwPYAw=; b=ArQrN9nGN4jFspIIvE/gpvQJLlLTcYhrhs9ktzGd6LtB0RPqmzDkuodojC88xH4UnU fn1R0PIA4t4fTaZ46Nz0JfeRK1DHJitJzQgdazPxog6z5ZTubSSEf47xR2Z6hfd+J5cw 6ItHxhEX7HRQ4cF5IlO6ycMBA3n4BrBMgODu4ecqnJkrNagrI7As3bARq91oK1dR4wO8 C8P8DDw3BYf6J2rTHfEpXph/KIyqw6IzSq5ktemrtEIakwICtqkUHgajZhSmUyAqD9fP i6bYOc0gL9UWuFQcODnKgRW39EMhtGzRmNL6Z99FQD/zG6tXCEYbidtLRV7ZIqj/1V/v Z6Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xDOsFM1m8LjIPXzr05DKGgzHN2YIgV5IvXvx/lwPYAw=; b=dHjc//c5LnASf1na/SJ8AqVXPM0ilvGpnPblkEySKwDbokautxnw+C9rRC1j1uh0gL 9eHwJXuVvcqcWfJVCuIugPTO99VtobnuyyaLOpaCWhoRYBhiLw3FhbD/6ZSznaziBHLP x/WuRxoPN2XscayposirIQP4YLWTkMMMU6PTqvJLprZMuCaaU7U8T8EKuWedBQ/xGp/0 iVDYb72x2vw9W09GOR+vJ3mPWUoN7YijydlTMCoTlDK3z8ftLlbsqYbv0cNOqWDFZOqm 3W5P1GqEqDjB2eGI1cSktVPTZYotYo0Qv8/TBwF98fuOEjF41YM7aM+lQIXfJqV+XrMS GypQ== X-Gm-Message-State: APt69E3kxj5t43vZo0FIdlEPfEkH5XBXyD9ABCocuENi82yxpL+qGEUZ 6KzjBTtdIIwI77LlcVIa9M0= X-Google-Smtp-Source: ADUXVKK/Nswi8+lgoYyBh1aEOWobXgClAUQJCOnzm3JtqwkwLeSoOfp/bMfSAmjod+8iemuabwjrmA== X-Received: by 2002:a63:b147:: with SMTP id g7-v6mr4253600pgp.379.1528443717363; Fri, 08 Jun 2018 00:41:57 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id m9-v6sm97679408pff.41.2018.06.08.00.41.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 00:41:56 -0700 (PDT) From: Jia He To: Herbert Xu , "David S. Miller" , Catalin Marinas , Will Deacon , Ard Biesheuvel Subject: [PATCH v2] crypto: arm64/aes-blk - fix and move skcipher_walk_done out of kernel_neon_begin, _end Date: Fri, 8 Jun 2018 15:41:44 +0800 Message-Id: <1528443704-26850-1-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180608_004208_344529_9C7DEAE1 X-CRM114-Status: GOOD ( 13.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, jia.he@hxt-semitech.com, linux-crypto@vger.kernel.org, Jia He , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In a arm64 server(QDF2400),I met a similar might-sleep warning as [1]: [ 7.019116] BUG: sleeping function called from invalid context at ./include/crypto/algapi.h:416 [ 7.027863] in_atomic(): 1, irqs_disabled(): 0, pid: 410, name: cryptomgr_test [ 7.035106] 1 lock held by cryptomgr_test/410: [ 7.039549] #0: (ptrval) (&drbg->drbg_mutex){+.+.}, at: drbg_instantiate+0x34/0x398 [ 7.048038] CPU: 9 PID: 410 Comm: cryptomgr_test Not tainted 4.17.0-rc6+ #27 [ 7.068228] dump_backtrace+0x0/0x1c0 [ 7.071890] show_stack+0x24/0x30 [ 7.075208] dump_stack+0xb0/0xec [ 7.078523] ___might_sleep+0x160/0x238 [ 7.082360] skcipher_walk_done+0x118/0x2c8 [ 7.086545] ctr_encrypt+0x98/0x130 [ 7.090035] simd_skcipher_encrypt+0x68/0xc0 [ 7.094304] drbg_kcapi_sym_ctr+0xd4/0x1f8 [ 7.098400] drbg_ctr_update+0x98/0x330 [ 7.102236] drbg_seed+0x1b8/0x2f0 [ 7.105637] drbg_instantiate+0x2ac/0x398 [ 7.109646] drbg_kcapi_seed+0xbc/0x188 [ 7.113482] crypto_rng_reset+0x4c/0xb0 [ 7.117319] alg_test_drbg+0xec/0x330 [ 7.120981] alg_test.part.6+0x1c8/0x3c8 [ 7.124903] alg_test+0x58/0xa0 [ 7.128044] cryptomgr_test+0x50/0x58 [ 7.131708] kthread+0x134/0x138 [ 7.134936] ret_from_fork+0x10/0x1c Seems there is a bug in Ard Biesheuvel's commit. Fixes: 683381747270 ("crypto: arm64/aes-blk - move kernel mode neon en/disable into loop") [1] https://www.spinics.net/lists/linux-crypto/msg33103.html Signed-off-by: jia.he@hxt-semitech.com Acked-by: Ard Biesheuvel Cc: # 4.17 Acked-by: Will Deacon --- v2: cc stable --- arch/arm64/crypto/aes-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index 253188f..e3e5095 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -223,8 +223,8 @@ static int ctr_encrypt(struct skcipher_request *req) kernel_neon_begin(); aes_ctr_encrypt(walk.dst.virt.addr, walk.src.virt.addr, (u8 *)ctx->key_enc, rounds, blocks, walk.iv); - err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE); kernel_neon_end(); + err = skcipher_walk_done(&walk, walk.nbytes % AES_BLOCK_SIZE); } if (walk.nbytes) { u8 __aligned(8) tail[AES_BLOCK_SIZE];