From patchwork Wed May 4 09:52:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 9012021 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3D0589F1C1 for ; Wed, 4 May 2016 09:53:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B9222038F for ; Wed, 4 May 2016 09:53:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88E052038D for ; Wed, 4 May 2016 09:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751311AbcEDJxJ (ORCPT ); Wed, 4 May 2016 05:53:09 -0400 Received: from helcar.hengli.com.au ([209.40.204.226]:44302 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbcEDJxI (ORCPT ); Wed, 4 May 2016 05:53:08 -0400 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by norbury.hengli.com.au with esmtp (Exim 4.80 #3 (Debian)) id 1axtUJ-0004WM-E8; Wed, 04 May 2016 19:52:59 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.80) (envelope-from ) id 1axtUH-0007DP-CB; Wed, 04 May 2016 17:52:57 +0800 Date: Wed, 4 May 2016 17:52:56 +0800 From: Herbert Xu To: Steffen Klassert Cc: Sowmini Varadhan , linux-crypto@vger.kernel.org Subject: [PATCH v2] crypto: hash - Fix page length clamping in hash walk Message-ID: <20160504095256.GA27632@gondor.apana.org.au> References: <20160421071451.GE3347@gauss.secunet.com> <20160425100527.GA9521@gondor.apana.org.au> <20160428082743.GO3347@gauss.secunet.com> <20160503095531.GA18007@gondor.apana.org.au> <20160504093420.GB3347@gauss.secunet.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160504093420.GB3347@gauss.secunet.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, May 04, 2016 at 11:34:20AM +0200, Steffen Klassert wrote: > > Hmm, the 'sleeping while atomic' because of not unmapping > the page goes away, but now I see a lot of IPsec ICV fails > on the receive side. I'll try to find out what's going on. > > Sowmini, could you please doublecheck with your test setup? Don't bother, my patch was crap. Here's one that's more likely to work: ---8<--- The crypto hash walk code is broken when supplied with an offset greater than or equal to PAGE_SIZE. This patch fixes it by adjusting walk->pg and walk->offset when this happens. Cc: Reported-by: Steffen Klassert Signed-off-by: Herbert Xu diff --git a/crypto/ahash.c b/crypto/ahash.c index 5fc1f17..3887a98 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -69,8 +69,9 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk) struct scatterlist *sg; sg = walk->sg; - walk->pg = sg_page(sg); walk->offset = sg->offset; + walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT); + walk->offset = offset_in_page(walk->offset); walk->entrylen = sg->length; if (walk->entrylen > walk->total)