Received: by 10.213.65.68 with SMTP id h4csp684709imn; Fri, 6 Apr 2018 07:16:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx48CFPli0ts/DFG7TgRFgGYHQk1gs5xvg0Sw4WupGRRlaiUwVF7UV+Ych9tG4jRch0SYRjzl X-Received: by 2002:a17:902:7785:: with SMTP id o5-v6mr25733756pll.356.1523024205609; Fri, 06 Apr 2018 07:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523024205; cv=none; d=google.com; s=arc-20160816; b=OYbncN5l5abLhMgc5+3oB0uo1dEEV21tDdoPqetslh5V8cKAIlS7iTQ73X/gd7fGE/ AbMoQ79godBaYEq/XcKRKDmkOZv3aZdMjRPSF7kX86rN4qUa1DzsBpLMZXKflOa1zoW7 4h4omR3o1BQQbg2Yxx7Umm+1o07qW+U5FuPFYgcmhGVHpsZ08j3DlismXnRjCga/FLo/ Ao5Td7d0KGHMyupoqcz4yBaj19auViTXEvU6BQH/I0PiLRCYrWMZmwBR2nfPfGjt+8YK tP5SPh2HYi8XTpIksOPsU7ICvb0hV6sfky+plVtkuFhoi8kcDxm7dzzgQh7eK8bNjf35 zJ4A== 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=7n3QOIkNX2r6d6/enTJNZUSjlLuGPrXWdGbdYoKh828=; b=U9hUl6kCDapK66+vcaHH6Tvug6utyeIHzZBMRe7h9annmJ201FxmWKKryOe+pscr5b vbv2HY9VtGm8JO5v8XnEtqKiySA92aorhtcd1EKV3mOZIrkN+UEIthu5i4oGKD1XSMYg CIziZ7ZRmKXNky4i8BLrT0wTKfjakaNtj2fVC4EWBek9CkE3n+SrcMQJDq6omyY4/szs VvFvclPg33aPkvag050l2FU9aG4pC+VYxPNqjxSiNm846UF3C353riAXLCAnfylmTl+1 /DtexcdjFSBMi0IAfwA45ltpHt8o0s+a5u8Fw1zyocjrRIWDZtLLPIU7KLMe1hRv7Nio qvgQ== 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 u206si7161826pgb.321.2018.04.06.07.16.31; Fri, 06 Apr 2018 07:16:45 -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 S932633AbeDFNj0 (ORCPT + 99 others); Fri, 6 Apr 2018 09:39:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34434 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932608AbeDFNjV (ORCPT ); Fri, 6 Apr 2018 09:39:21 -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 8A6CDD17; Fri, 6 Apr 2018 13:39:20 +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.14 49/67] crypto: ahash - Fix early termination in hash walk Date: Fri, 6 Apr 2018 15:24:19 +0200 Message-Id: <20180406084347.586903877@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@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.14-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 @@ -92,13 +92,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)