From patchwork Wed Sep 9 12:27:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 7146181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D4CB0BEEC1 for ; Wed, 9 Sep 2015 12:31:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C57F20982 for ; Wed, 9 Sep 2015 12:31:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DD2D20883 for ; Wed, 9 Sep 2015 12:31:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZeTp-0002if-Pc; Wed, 09 Sep 2015 12:28:01 +0000 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZeTm-0002Vt-Fw for linux-arm-kernel@lists.infradead.org; Wed, 09 Sep 2015 12:27:58 +0000 Received: by wiclk2 with SMTP id lk2so19800044wic.1 for ; Wed, 09 Sep 2015 05:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=m2dbq7CTbK2ifRu9dMWpbAY4VJRmlFzZEQDr3OBAVhg=; b=kTWMJU3DJoavq0nbQgNEoLkYDOu8xAV6NcDefeVnJmQQdx9jGrD2kVNix84yP7YjvT Z7wnWUi63YBBKVNXth4wL6HXYcSK0tU7pNsLG7eDp15/XFuL9rBYbbq8mUmyhS4Smdfe jyPIjsNNbuuR9PjJMd4XzjlacSWfP06lZkzm3ABxztUYxUgk1XVX0FyVDGdwrkHpSUB3 ZGZrOhY2QCJRNgq3mBz0T/BgMQaazqEO4PY2GblT+RUtSKYWcDXyYrTa5LRhmFiRmV75 rVMUDIMZp/pbYiY19fBDcD6Ywd/TCHfScZ0bEbHfsEHFWftjqgzDvTqo5yS4F6wWUJjH aYqA== X-Received: by 10.194.94.165 with SMTP id dd5mr60460450wjb.40.1441801656404; Wed, 09 Sep 2015 05:27:36 -0700 (PDT) Received: from Red.local (ANice-651-1-193-212.w83-197.abo.wanadoo.fr. [83.197.249.212]) by smtp.googlemail.com with ESMTPSA id fx2sm3612568wib.24.2015.09.09.05.27.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 05:27:35 -0700 (PDT) From: LABBE Corentin To: herbert@gondor.apana.org.au Subject: [PATCH] crypto: sun4i-ss Fix a possible driver hang with ciphers Date: Wed, 9 Sep 2015 14:27:07 +0200 Message-Id: <1441801627-31820-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150909_052758_712033_C8144003 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maxime.ripard@free-electrons.com, LABBE Corentin , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sun4i_ss_opti_poll function cipher data until the output miter have a length of 0. If the crypto API client, give more SGs than necessary this could result in an infinite loop. Fix it by checking for remaining bytes, just like sun4i_ss_cipher_poll(). Signed-off-by: LABBE Corentin --- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c index e070c31..a19ee12 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c @@ -104,7 +104,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) sg_miter_next(&mo); oo = 0; } - } while (mo.length > 0); + } while (oleft > 0); if (areq->info) { for (i = 0; i < 4 && i < ivsize / 4; i++) {