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: 7146161 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@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 343C0BEEC1 for ; Wed, 9 Sep 2015 12:27:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54C3620884 for ; Wed, 9 Sep 2015 12:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F5412085E for ; Wed, 9 Sep 2015 12:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752147AbbIIM1i (ORCPT ); Wed, 9 Sep 2015 08:27:38 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:33544 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751650AbbIIM1h (ORCPT ); Wed, 9 Sep 2015 08:27:37 -0400 Received: by wiclk2 with SMTP id lk2so155210204wic.0; 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 Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, maxime.ripard@free-electrons.com, linux-arm-kernel@lists.infradead.org, LABBE Corentin 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 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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++) {