Received: by 10.213.65.68 with SMTP id h4csp649989imn; Fri, 6 Apr 2018 06:46:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/tRYNl9CofAm4u8EpqVIN6sh2XFNxwjc0ZHomBtX+acOU6sE0RyOtuLitKq3uMJPoeMImH X-Received: by 2002:a17:902:28a4:: with SMTP id f33-v6mr26861733plb.115.1523022379893; Fri, 06 Apr 2018 06:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022379; cv=none; d=google.com; s=arc-20160816; b=r9udn4FYb6zKntykYP3NHIFMWLAwUNXYwHbQraD0p4NGxX3qyfG25AeOksDZgjp2bD dvXv1dBlwMftJN8kIsOSQO5bQqxEo1IgkahZdleMufR5C5L/EFuQCv+si0xFPhupwg4E WlcbhRgdrtDEY2zV+h/soO7vNIDq60hB+c94js7Y0g3HoXXrVy6pQXPkdgnDeshYFjBF WWgAVgw8mQ9lX0R02+aPBEaqVnvSL3gYpwcSH7lK6xdybN0+4k8XuF1Oh5PggQ3sZv/n Q/LbLnUNj83dnjWh4T+GGPRVxHgAhqNdyoLsc0x/Xd7d4tRV/a3KGuUIIyNKgwurhv4p k/jw== 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=qdaw3l1PSr33HEJk+Gar4qR217PAys11tUAROn2onV4=; b=uYvvSoiB3RNvKxmPNmb6hDgwKre5dytBBTDuqKFlbxtDj9+L5dQEateMWeV2Q0442H izGoJJQH3UUiCp5ZB4XUuJkLA7cJlz79b9ovJ+f+hoDlMMv6DDTpx4aW8auAzCJzTUuk rGasW364C5VC8mdwcHAsbiJbHCcad9fKIEo6EY1rk82/V02ULbELHHYAue/NDpgJBg0F WWce2pQOiDUYxu2FPF1xeYMtLIeL06+ziUYkkaQeuupdTIJDLwK3rCUpmnkeSF9xKvRg JdGA9iwQN56nBGgLKOuqUUVdvyl8VANoAE6ApCmCtPA5E43aJZXraMnb+W61Qgwl8tV3 nTcQ== 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 z85si8052845pfk.194.2018.04.06.06.46.06; Fri, 06 Apr 2018 06:46:19 -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 S1756843AbeDFNn6 (ORCPT + 99 others); Fri, 6 Apr 2018 09:43:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37494 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbeDFNn4 (ORCPT ); Fri, 6 Apr 2018 09:43:56 -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 54D1BE07; Fri, 6 Apr 2018 13:43:55 +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.15 54/72] crypto: ahash - Fix early termination in hash walk Date: Fri, 6 Apr 2018 15:24:29 +0200 Message-Id: <20180406084353.157641229@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084349.367583460@linuxfoundation.org> References: <20180406084349.367583460@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.15-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)