Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp277520ybi; Wed, 29 May 2019 21:13:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWX/Dhai8gp4akBryI31LdgQaG5Gfy3AEROknsAe8iexslXQgR8kilCeAIsxFkr6DaSzK0 X-Received: by 2002:a17:90a:ae02:: with SMTP id t2mr1569757pjq.41.1559189605732; Wed, 29 May 2019 21:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189605; cv=none; d=google.com; s=arc-20160816; b=iJb0zYoNzPzjI+zkB2Q8dVNz273CoY5Rh7zzerpTLOQ2yUI1Dt2UeVebaWK4IKuDe3 /zTGP33PGEnVLE6aXgDCCII7xCbkVdY/qRFXxMddUWgiSVFku/sqwiFEwHrKnbdkXKCo q/Dh6xDqKsCPsn/wjHYeg/1Th7QmdUhelTymKlcYteTEaRwdUSakT6Iz6MafKawLHz4v XBffanFpivvKSy2uNdmu4BPw9xUHb4MaYQo+3b0rlcRPcNNfWDY+6x8GnWy809jnAoRb sCHBMr6uwMuFxf+g6zGuuTKXUfJV9ooC21oCc47cg2OOQYPmtFqVtRGztADf1GP5DPKD 8kug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mj3rjpIyGvVqgveWI2KYvbqNr5eaV2eh8wXA/qj0S4o=; b=frNU9kdE6bI16jBvqPEMtOVq3J2Jjk8Pab3wB77OjXDZ6BSO7jUz+j3umGvliOLPdx uFWusNTUxW5dpLR/a3v+lHmxzfxtNcx+yXQsBnLqeuzzwNJKV/sy33+bqswQAq8oRWqB kokiEDk3Jg5HeEQ0jLj5nIub6vmk6NRzpViVwrpvGe9II88g+3F3IEqmEh6Ry+0RZnp3 UEPpHbDtU1+UQShTEFWopnFxEs3iU8/hLz1fjfdiyH+G9u4d2kLQhiG8h9eK/ILeNBwR Aj5PQgL/cHRKfJW/m3RGK4MoucvfoJ6ajJCOxXxBKDlYwJJTfGo0k3Yb3YSXg2mZY4Bk udZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=doPU2SrB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si1148609plm.209.2019.05.29.21.13.10; Wed, 29 May 2019 21:13:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=doPU2SrB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729604AbfE3ELQ (ORCPT + 99 others); Thu, 30 May 2019 00:11:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:44202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730834AbfE3DQu (ORCPT ); Wed, 29 May 2019 23:16:50 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 13D1F2463E; Thu, 30 May 2019 03:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186210; bh=MebKhiyvJ7riAHzHPq/RqDHrA7XgxeH37Lqj5HQRhYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doPU2SrBSKbpU1GOxtOUnXA3duZP7hNoos/QWfoabN3Z5Uo5kOslCSSwB6EyB1VGq 15YzOJMQvKBJD5OFba8AGKpcu1x8gualbCfz3w3MguS2EJhd1Ut1Lrx1+dciU/3siz nvbv3yR84ypxu5qqt2Oq31TmSEXA+8YPXY1h2Ecc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Corentin Labbe , Herbert Xu , Sasha Levin Subject: [PATCH 4.19 101/276] crypto: sun4i-ss - Fix invalid calculation of hash end Date: Wed, 29 May 2019 20:04:19 -0700 Message-Id: <20190530030532.410028712@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit f87391558acf816b48f325a493d81d45dec40da0 ] When nbytes < 4, end is wronlgy set to a negative value which, due to uint, is then interpreted to a large value leading to a deadlock in the following code. This patch fix this problem. Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator") Signed-off-by: Corentin Labbe Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c index a4b5ff2b72f87..f6936bb3b7be4 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c @@ -240,7 +240,10 @@ static int sun4i_hash(struct ahash_request *areq) } } else { /* Since we have the flag final, we can go up to modulo 4 */ - end = ((areq->nbytes + op->len) / 4) * 4 - op->len; + if (areq->nbytes < 4) + end = 0; + else + end = ((areq->nbytes + op->len) / 4) * 4 - op->len; } /* TODO if SGlen % 4 and !op->len then DMA */ -- 2.20.1