From patchwork Thu Nov 23 12:49:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?T25kcmVqIE1vc27DocSNZWs=?= X-Patchwork-Id: 10072749 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7291F60353 for ; Thu, 23 Nov 2017 12:50:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6814B29D73 for ; Thu, 23 Nov 2017 12:50:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59C7C29DA7; Thu, 23 Nov 2017 12:50:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0501829D73 for ; Thu, 23 Nov 2017 12:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752365AbdKWMuA (ORCPT ); Thu, 23 Nov 2017 07:50:00 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:46812 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751911AbdKWMt7 (ORCPT ); Thu, 23 Nov 2017 07:49:59 -0500 Received: by mail-wm0-f65.google.com with SMTP id u83so16724223wmb.5; Thu, 23 Nov 2017 04:49:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FZLtAuCL1cjXLZOwMYjDw6X2sEJ8Wtd2Bbiy6jsSQrA=; b=VoyFMjerwJw7qPniqfZSSEJJD5M1J046uPfvWwWBNI4Qz+hd1kibM5tnVqehMMuJk0 SyAf8edrH1rCzJCysCB3n3CPy3R9jFBedku2qZd60jYeApkuSW4Z8tCxWEDkO32ReDg+ vdXQ/dxl04JfZ+Rgois6sqc50FEEuw+uYHovV+e0gkBKG6C8mXfQ/bTnEXp6i10bVKe2 Qwvu46gigLTjXeMLfDGgjEsJTLGFAFiKwwuEXa5BqboF7vEOhF6N/T7D8/znkJjNQ4E/ 9eqU5iXQ/4rVV2Q7vnyZvIIVXw4q1CbmmZB9YZOTIcPs8vn1shd1oacLAISlT4Z/EcD2 WjaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FZLtAuCL1cjXLZOwMYjDw6X2sEJ8Wtd2Bbiy6jsSQrA=; b=of2jL1r+15Nzu9Or6XRPKPkNq3ahwQm1EeP1OPKyzSVDZX7mIOs9IQngkyE+H/xGBK sDzC0Lk/qV18x5uoaP5kQTU3xdCRWmnzHoeeQ22ZsuIKKyRX91mXiFQL/syRjU6+7DCV FDbOOBzcyGsbfCcx5I3EAGK+tZSNDZkUZhoQoc1wxjr0oZDiGymSsHLvp6fedm7rrQv7 wBsbdUhoQS4wMdgR5niUOzMoy9DAU4xcFSgstN7fCt9xDB4E5fUMCtJ9QgxDyDKVMzhC vZ8RIUg4CkZe/7COpT2osf8amkmNYOOc7Zfb97ex1PkUE0OJS3Uaa4jpeu32VQuPIRGX wndQ== X-Gm-Message-State: AJaThX75Xa18hpzykvOFTCY8Q8PYhRONFjaBR7PjMD0NCgrz4KqvWQeb 20LpvtaEpMSp3OVeZf3oC8E= X-Google-Smtp-Source: AGs4zMa9NOGvBuiPsxTjR6Yhu3lHhJq882RfltS1+dCoFCqRo1dmtlZ6KKUKekIiABv5ltKr4MqB3g== X-Received: by 10.28.59.133 with SMTP id i127mr7310057wma.30.1511441398494; Thu, 23 Nov 2017 04:49:58 -0800 (PST) Received: from localhost.localdomain (bband-dyn3.178-41-110.t-com.sk. [178.41.110.3]) by smtp.gmail.com with ESMTPSA id d4sm6993783wmh.35.2017.11.23.04.49.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 04:49:57 -0800 (PST) From: Ondrej Mosnacek To: Herbert Xu Cc: Ondrej Mosnacek , "David S. Miller" , linux-crypto@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] crypto: skcipher - Fix skcipher_walk_aead_common Date: Thu, 23 Nov 2017 13:49:06 +0100 Message-Id: <20171123124906.15754-1-omosnacek@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The skcipher_walk_aead_common function calls scatterwalk_copychunks on the input and output walks to skip the associated data. If the AD end at an SG list entry boundary, then after these calls the walks will still be pointing to the end of the skipped region. These offsets are later checked for alignment in skcipher_walk_next, so the skcipher_walk may detect the alignment incorrectly. This patch fixes it by calling scatterwalk_done after the copychunks calls to ensure that the offsets refer to the right SG list entry. Fixes: b286d8b1a690 ("crypto: skcipher - Add skcipher walk interface") Cc: Signed-off-by: Ondrej Mosnacek --- crypto/skcipher.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/skcipher.c b/crypto/skcipher.c index 4faa0fd53b0c..6c45ed536664 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c @@ -517,6 +517,9 @@ static int skcipher_walk_aead_common(struct skcipher_walk *walk, scatterwalk_copychunks(NULL, &walk->in, req->assoclen, 2); scatterwalk_copychunks(NULL, &walk->out, req->assoclen, 2); + scatterwalk_done(&walk->in, 0, walk->total); + scatterwalk_done(&walk->out, 0, walk->total); + walk->iv = req->iv; walk->oiv = req->iv;