From patchwork Mon Jan 7 23:15:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10751281 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAF6614E5 for ; Mon, 7 Jan 2019 23:16:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9ADB28AAA for ; Mon, 7 Jan 2019 23:16:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB72828AD5; Mon, 7 Jan 2019 23:16:43 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 561F828AAA for ; Mon, 7 Jan 2019 23:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfAGXQh (ORCPT ); Mon, 7 Jan 2019 18:16:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:44312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbfAGXQh (ORCPT ); Mon, 7 Jan 2019 18:16:37 -0500 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34FD02147C; Mon, 7 Jan 2019 23:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546902996; bh=4RXHtF99KpnXKbfBQG9H9y32tNc6cHnZZPAtVvlgk64=; h=From:To:Cc:Subject:Date:From; b=Ha9K8CRlvZRqCI86Q1DBRVbLMJxiyUM3cCqakhYLDxDFTcziGRcXRUeJi2x3qPnz5 gk0Qw46K9J3bUpF1nFPuDYPCZ8Qe0BT2hL3e+d6MjBOBiDIvSaL3ry9QQT8cSD26XM Sa87/aBY6DKA34zlcOLSh2d6xsIsnZaM78fJAmoQ= From: Eric Biggers To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: linux-crypto@vger.kernel.org, Martin Willi , Ard Biesheuvel Subject: [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled Date: Mon, 7 Jan 2019 15:15:59 -0800 Message-Id: <20190107231559.13357-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers Hi Greg, please consider applying this to 4.9-stable and 4.4-stable. It's a minimal fix for a bug that was fixed incidentally by a large refactoring in v4.11. >8------------------------------------------------------8< In chacha20-simd, clear the MAY_SLEEP flag in the blkcipher_desc to prevent sleeping with preemption disabled, under kernel_fpu_begin(). This was fixed upstream incidentally by a large refactoring, commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86 versions to skcipher"). But syzkaller easily trips over this when running on older kernels, as it's easily reachable via AF_ALG. Therefore, this patch makes the minimal fix for older kernels. Fixes: c9320b6dcb89 ("crypto: chacha20 - Add a SSSE3 SIMD variant for x86_64") Cc: linux-crypto@vger.kernel.org Cc: Martin Willi Cc: Ard Biesheuvel Signed-off-by: Eric Biggers Acked-by: Ard Biesheuvel --- arch/x86/crypto/chacha20_glue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/crypto/chacha20_glue.c b/arch/x86/crypto/chacha20_glue.c index f910d1d449f00..0a5fedf43bdc8 100644 --- a/arch/x86/crypto/chacha20_glue.c +++ b/arch/x86/crypto/chacha20_glue.c @@ -77,6 +77,7 @@ static int chacha20_simd(struct blkcipher_desc *desc, struct scatterlist *dst, blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt_block(desc, &walk, CHACHA20_BLOCK_SIZE); + desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; crypto_chacha20_init(state, crypto_blkcipher_ctx(desc->tfm), walk.iv);