Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1937952imm; Thu, 24 May 2018 03:14:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqU49/ELYxdBY+0rc/NY/ZoDcW8R+HB7f4qRtnJBFBQd54yPo8ItqkfyJodt1ji1Rj1TDqi X-Received: by 2002:a17:902:20e5:: with SMTP id v34-v6mr6738612plg.127.1527156899320; Thu, 24 May 2018 03:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156899; cv=none; d=google.com; s=arc-20160816; b=bgrAUlccsQk2+NuA83kAd5i2js6/pOqwD7HpexoacyZ6eKyP8/18hrVoHdaSGmgBys /a2/KWvgEsDAHAmsI4a3GR/VALMPtg+G8pkpYdIukb/kJEy8xALw6qgRzP2b2vO+38Mp KVG3+9MPKznp5Ef+SyXvRl2r4qsXSK6sfU3qzY7hPtIMOcOeala/8xDgeWurK7Ztad5s jHELL/Lc/AgTbH3kAmyUu4c/902skS/QK7crLYZeVtxBVDVy2b5WKFL6BGHadzw3idJF UUKcHCxF9cV9TJZxHZ0u/HGXOCWWJAcAOUyXQJBW0d6QLx2Px7rGalj5kwmKkljkzhOm 2Ylg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Oj/vzqPygBKGjCk0fSus5JuUhUwpsA3x5l8JIbdXdgE=; b=Pz/5CKcSc1d/O2yJnVq/2oniLdEh5Qlzd1eZP+mh8JyP6w3NilTJ3yFQhZFKm7IqOm dfm4VKruAzF4fz1tv7LKOKMX0o67MfCG0E+6Mm0cK2NFvO1rAb7QyPd0k7shdez8uqEC 5qUpNuGym0lrthIyvNB/q00Bpv93j8uIXWRCUIufjsIHVbyW1ErzFphDO+tq9k+eNcwO gH/lA3yYzm3wouENwx0frHIvWfGcRZanU0YdIXzQ5tqglqnR3+r3ZeWzF9zMH7rUy73V CP84TLMzoiN1qqgNIX5I6gj2+7WOVZdpr6Z+zW0+p0geWYXir91uKAepG/nMMvSCmXLQ FThA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TIvl71n7; 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 3-v6si21653860plf.84.2018.05.24.03.14.44; Thu, 24 May 2018 03:14:59 -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=TIvl71n7; 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 S1031813AbeEXKMu (ORCPT + 99 others); Thu, 24 May 2018 06:12:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:54266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031571AbeEXKFD (ORCPT ); Thu, 24 May 2018 06:05:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 E770320896; Thu, 24 May 2018 10:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156302; bh=7EoxZob8b3xZc6v77oC7xdgtKNntut7+v0JFxAQqX64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TIvl71n7YtVEPhMeHB4at3KgMm4/y702N+IwynG/zjD+5caKnYxBmtD8efcr8WfaT DQjum1ZE77E2c5h40XpZU/QTY13RDt7UZHKmUrK4SFFaPK1NHav5/dc7rYsI3TifjV LDmwEX+/DLcJTPgcNs7Nhd8izEuJUOzRNsdA7ijI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antoine Tenart , Herbert Xu , Sasha Levin Subject: [PATCH 4.16 102/161] crypto: inside-secure - fix the cache_len computation Date: Thu, 24 May 2018 11:38:47 +0200 Message-Id: <20180524093030.641944064@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Antoine Tenart [ Upstream commit 666a9c70b04fccabde5cea5e680ae1ae92460a62 ] This patch fixes the cache length computation as cache_len could end up being a negative value. The check between the queued size and the block size is updated to reflect the caching mechanism which can cache up to a full block size (included!). Fixes: 809778e02cd4 ("crypto: inside-secure - fix hash when length is a multiple of a block") Signed-off-by: Antoine Tenart Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/inside-secure/safexcel_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -187,7 +187,7 @@ static int safexcel_ahash_send_req(struc int i, queued, len, cache_len, extra, n_cdesc = 0, ret = 0; queued = len = req->len - req->processed; - if (queued < crypto_ahash_blocksize(ahash)) + if (queued <= crypto_ahash_blocksize(ahash)) cache_len = queued; else cache_len = queued - areq->nbytes;