Received: by 10.213.65.68 with SMTP id h4csp705733imn; Fri, 6 Apr 2018 07:34:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/09jBsv5vPzMx8QWWFqWZ/CwCAjAvw4uA1WLclKsV6jU1DHkTi61ehT1Mqb69kLMRYHNHm X-Received: by 2002:a17:902:bc04:: with SMTP id n4-v6mr27616540pls.97.1523025296641; Fri, 06 Apr 2018 07:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025296; cv=none; d=google.com; s=arc-20160816; b=oZGmG3UTZnBo8u75QUNzVFYJwPgbDJIPAjN0wU51+TxutkETBvdDtFPZs9PiRxRSUL 9ww9uejHDYn9naJJ30qtdgsJdSaW0Tf7W8DR3JD0G1JhbhDOa9+I1qWzwldI3piSXs2V mp6YjRfqYqJa5+AkoISkMbK5d0YXEl6iSu3jbQyCktHl8XOBwSdSNfnpHQjGWMFs3q5O OvExv2FjoyHG9sgGtiF5jsp3kVlQFZENj7OoIzr3dumflCG9C1CDYmQznDmLdDLLOZky ym8xVZFdC6kBtASBnJlypxr5H38BxZ6b1NUBP2cZMGw7IJHgRzJLIBB2B/pXYKrfimzV 70kg== 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 :arc-authentication-results; bh=LPPEhJhSWvLCytud4rARW1UJuvOaP8WRdGLOvCzXIJA=; b=SeHYAsKgMag3Y7QV004i1Ww6++u9ehHL2uoK+BG6zv2pMGFpi4ABhe3aQdx+WQwhA5 TsVhLQ5TkMgv8or8uODAgsY99DJ5kV3Nl5hp0PYexY9oXx64ROMpqSq22CN8sT3S5c1z TTkDWU535rrE3rEQZdEBiwk+HK2XnHssIGevOQe6a6KjBV+zxIhP8iLKu4UU5Pf4v8YU PtfXo037ceTVhD9mWxMYudI974uTx8YZRzLyyPUa5TfwEBf3oIshJL5kUrV6Jx+rs2Lw Qps9qE8VoZCC6rjI9SNCNuf1iQIhiGdb/o7cWegQ7MnzRY5RhE2dXsQyPQ4lJDwbjFHf rbNg== ARC-Authentication-Results: i=1; mx.google.com; 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 l18si7235189pgn.744.2018.04.06.07.34.42; Fri, 06 Apr 2018 07:34:56 -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; 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 S1756172AbeDFNgI (ORCPT + 99 others); Fri, 6 Apr 2018 09:36:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59036 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756143AbeDFNgE (ORCPT ); Fri, 6 Apr 2018 09:36:04 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B2F6DC5; Fri, 6 Apr 2018 13:36:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eli Cooper , Herbert Xu Subject: [PATCH 4.9 083/102] crypto: ahash - Fix early termination in hash walk Date: Fri, 6 Apr 2018 15:24:04 +0200 Message-Id: <20180406084343.115461865@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Herbert Xu commit 900a081f6912a8985dc15380ec912752cb66025a upstream. When we have an unaligned SG list entry where there is no leftover aligned data, the hash walk code will incorrectly return zero as if the entire SG list has been processed. This patch fixes it by moving onto the next page instead. Reported-by: Eli Cooper Cc: Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/ahash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -91,13 +91,14 @@ int crypto_hash_walk_done(struct crypto_ if (nbytes && walk->offset & alignmask && !err) { walk->offset = ALIGN(walk->offset, alignmask + 1); - walk->data += walk->offset; - nbytes = min(nbytes, ((unsigned int)(PAGE_SIZE)) - walk->offset); walk->entrylen -= nbytes; - return nbytes; + if (nbytes) { + walk->data += walk->offset; + return nbytes; + } } if (walk->flags & CRYPTO_ALG_ASYNC)