From patchwork Thu Apr 18 08:17:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10906631 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 CC44F1515 for ; Thu, 18 Apr 2019 08:18:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B22D328C1E for ; Thu, 18 Apr 2019 08:18:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A65F328C34; Thu, 18 Apr 2019 08:18: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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 5AF3428C1E for ; Thu, 18 Apr 2019 08:18:43 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=Z0gRea4AdeJrlj8f2EILkD19ijB+3172SXV4JtJKYE8=; b=Udwch+RIL+MWl1 Cc4oWhnPTIjqXnUygEtUbgk7DiZgSgn+Lw82rIPIWHUW3sOt09WAOII4cusRzgHUneukiO2cs6u+d +KyMp9rteHa8Hti+dR9CjmScbrfruRh4VKr91mf1iWWHsUEv/Spcit3AKlCMkVbRAbg8QGNjKhjXm J4amdf8zKy1znGgpy5YWmhvuIFKO5eTLdrkCAB28WwfKmSBtxggPoSs0fzoBRxhRG86IVBkpCcDNG ngDudd3LomAgPodTWeE6Q3D+ULeyl+U/la3hk95YdHmp/Q/YgCAWF9n/U5sUEaN0eG+9CqJ+fZK1D IQW/AcdVeAP1y25Q14vw==; 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 1hH2Fj-00050s-O7; Thu, 18 Apr 2019 08:18:39 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hH2Ez-00047L-TQ for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2019 08:17:56 +0000 Received: by mail-wm1-x342.google.com with SMTP id a184so1714089wma.2 for ; Thu, 18 Apr 2019 01:17:53 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=z5FqXHUkkOxiPqY9isBq9yK5Qx1B2t+uIrpEWzqHhn4=; b=ScQFT3IFvQa3euQsJP1/Jz+BGtaJxiOW7DbwNa0GEW0uzJdXZjsVsr1ixuuH+SDaof C3Nlzbc13LL7Z6bDjxnnceYseWsGmSGaKuVBmfTnCTsp5tm1TrPtTSruQIRKFPJFFpCL yCJEGWXHfNbvUEOzMnnTYF7box5TzYUHuZL2itCwVP7NWbVUUBab1aNxQK9uwLBJpKxF pyNbKowIkgsmzRaYpMP3J8XRL3+QvYX74O+trtA//jC81NVb6i2TqC7Jtqe9xtDij4lt YpfxXiwQ1ieUgyC30tX5zTCFsbTkfxqjrVcnRCvkyZdfjXKbV5u5Fj1T+e/pF7l5jgYV zkfg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=z5FqXHUkkOxiPqY9isBq9yK5Qx1B2t+uIrpEWzqHhn4=; b=C+ADOrlFb6JCMlpe+CSg0P1fhmKikHGzc0ZuRpLgmY/Z/xLjyeTCrvsKbfaqiNbp00 fwbbZgyWG1PcsuNTWhZRB0DUEboPU2Hg/qV4n6CG5vQt0oo0zCmSJp8g72F8uYDVw1CH VUUMiwMXgEwjLyB3NvMf9Sszi9UkggjxDruummoMNSRAdbJ16HgvfjnbH5LWLXs8FVu3 gF71RRCiU1nCKenRt+y7isBtCS5UqbAxswL0rP2KgkHhf9DBvPZcBP8FcYT9wro//FE/ wFTg5/6ZykFI3DsCy35GjivtlQx7lrSk87SjzjXz1+wivhbMhCNei82fdSLTfYMtVhfq AKPA== X-Gm-Message-State: APjAAAVJAxnYyhzj1+9laO4MRe7ir/dXj8+5UlNS97agKyer0sIQc0R5 5+He7Trz+LIkNmjY8pJf4Ss= X-Google-Smtp-Source: APXvYqxOJJGqvqm8GMhlQeF9XODmg5oHOxr6NI3SDMdQJl+Z8fVYcMK2cP6yM7YiAKz9TiRU4RLGxw== X-Received: by 2002:a1c:4602:: with SMTP id t2mr1991850wma.120.1555575472351; Thu, 18 Apr 2019 01:17:52 -0700 (PDT) Received: from Red.localdomain ([2a01:cb1d:147:7200:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id w11sm2350619wre.15.2019.04.18.01.17.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 01:17:51 -0700 (PDT) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, maxime.ripard@bootlin.com, wens@csie.org Subject: [PATCH 3/4] crypto: sun4i-ss: Fix invalid calculation of hash end Date: Thu, 18 Apr 2019 10:17:34 +0200 Message-Id: <20190418081735.19002-4-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418081735.19002-1-clabbe.montjoie@gmail.com> References: <20190418081735.19002-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190418_011754_012883_8C562E9E X-CRM114-Status: GOOD ( 13.07 ) 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, ebiggers@kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 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 --- 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 a4b5ff2b72f8..f6936bb3b7be 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 */