From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D740AC04AB4 for ; Fri, 17 May 2019 12:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9BC820879 for ; Fri, 17 May 2019 12:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558096408; bh=NCIVfYA2pTS/BXURAOPdm1Z/XuaXp7GpZKPrTr6zWZg=; h=Subject:To:Cc:From:Date:List-ID:From; b=x/74iW5rMGFXzdpx0nlv6YF60XrK9SNLhhNY2ekWltiNH8ONywpXWDdlxiAsuJTnW E5u+ABYXEAtLXlV650XtzKdnfiTG4XpQh4QYJBvJY/PyT12QukvnqH5/UShI+dQbSl /8IJeaNP0ydvmb9Y8CswjFm4UEpe4bH8FltB1few= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728430AbfEQMd2 (ORCPT ); Fri, 17 May 2019 08:33:28 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:47477 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728387AbfEQMd2 (ORCPT ); Fri, 17 May 2019 08:33:28 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 189D247A; Fri, 17 May 2019 08:33:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 17 May 2019 08:33:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=s/ewSG b3vxKpJXW3pjhgh1aFk1w/ZvxzZ0kt/90Yi3w=; b=pIhgXxBBkAjzaREUrxfxcc LsSX8aQCjKsKMhdEN/3pwKzaKizqF3gtP8w2khQVErI5wmNmrpyYsPh08lAz/lkC eoPDqgxKXIIyT7d9+AGAoRfO7mny/tZ91CkAWEEvu/iC2o0lyPfB8eKoSFe6tMiS jh7Hsi5SXNtLokSdmBgqLqmicKLA3SIqvU+ImEnE9G6Bc2hJ1lLhBMKVLIOwcAfE yUUAeDXJT7VAEWFAH2LsXsUp2PizJmhjZNYWy4SgWqPjtA7Arfw9v7zflFNlsXCN sQdB68zF0OLWlOWn5uXVNbI7/o9Scv4lf0unF3NBoIQuVqFxutsiMaZjgXd13kYg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddtvddgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrghilhhfrhhomh epghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgepje X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 7E87E10379; Fri, 17 May 2019 08:33:25 -0400 (EDT) Subject: FAILED: patch "[PATCH] crypto: skcipher - don't WARN on unprocessed data after slow" failed to apply to 4.9-stable tree To: ebiggers@google.com, herbert@gondor.apana.org.au, stable@vger.kernel.org Cc: From: Date: Fri, 17 May 2019 14:33:23 +0200 Message-ID: <15580964033563@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.9-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From dcaca01a42cc2c425154a13412b4124293a6e11e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 31 Mar 2019 13:04:15 -0700 Subject: [PATCH] crypto: skcipher - don't WARN on unprocessed data after slow walk step skcipher_walk_done() assumes it's a bug if, after the "slow" path is executed where the next chunk of data is processed via a bounce buffer, the algorithm says it didn't process all bytes. Thus it WARNs on this. However, this can happen legitimately when the message needs to be evenly divisible into "blocks" but isn't, and the algorithm has a 'walksize' greater than the block size. For example, ecb-aes-neonbs sets 'walksize' to 128 bytes and only supports messages evenly divisible into 16-byte blocks. If, say, 17 message bytes remain but they straddle scatterlist elements, the skcipher_walk code will take the "slow" path and pass the algorithm all 17 bytes in the bounce buffer. But the algorithm will only be able to process 16 bytes, triggering the WARN. Fix this by just removing the WARN_ON(). Returning -EINVAL, as the code already does, is the right behavior. This bug was detected by my patches that improve testmgr to fuzz algorithms against their generic implementation. Fixes: b286d8b1a690 ("crypto: skcipher - Add skcipher walk interface") Cc: # v4.10+ Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu diff --git a/crypto/skcipher.c b/crypto/skcipher.c index bcf13d95f54a..2e66f312e2c4 100644 --- a/crypto/skcipher.c +++ b/crypto/skcipher.c @@ -131,8 +131,13 @@ int skcipher_walk_done(struct skcipher_walk *walk, int err) memcpy(walk->dst.virt.addr, walk->page, n); skcipher_unmap_dst(walk); } else if (unlikely(walk->flags & SKCIPHER_WALK_SLOW)) { - if (WARN_ON(err)) { - /* unexpected case; didn't process all bytes */ + if (err) { + /* + * Didn't process all bytes. Either the algorithm is + * broken, or this was the last step and it turned out + * the message wasn't evenly divisible into blocks but + * the algorithm requires it. + */ err = -EINVAL; goto finish; }