Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp107493yba; Mon, 20 May 2019 05:50:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJWfKM1m4FZX5LrcxQK/3F7vnogMgxLgTWWs0v7Yygiuu4EplRHSp5fsEOkEaDEpa+Hcmu X-Received: by 2002:a17:902:1126:: with SMTP id d35mr40184304pla.82.1558356652369; Mon, 20 May 2019 05:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356652; cv=none; d=google.com; s=arc-20160816; b=lbe0vWhSeFc9q+kGRDvd5+S7h1gxW80DJ9f9941LBrM/ED1+T7JV97HNeyQ+mGZ7XN Wa3lYxXBq8cdwCBadfNjFBDw1tsOBe1bD/IKsNtg6mTC2WD1jxnoKDoJrAfv2tfmPho4 ycqVwCzswA7ue83/kGT0lZwMY0mXdKs4ngp23gx9V8dWOGDZFqCgJmy4qpELQxMX0FfQ 6lsdIWzhg+g0CACVnRSYLotMVPZt/D9+vkr6pk+RxPZVMScmcODv/i5kj/v+nCJ1dafs 3GLauX1FruhN6qr09seVWhSvxwwvWMt1iJew26X+dJtS4YDXj2pjqpwkct/fswhkGYM8 UlDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FcZdjnh3vVXJ+ir4o4U4bl04nDT5GVCI8IRgyhrUU+M=; b=xLZmWYdD3XcQgElwSHIBRc06i99m7gGYafG694sn7Zfv9CecTfmlYeUBEGqaNcy+qC 9HQEE3SSYMjujGXPHMIXSBapNmnDvpHeYhhYz4RG2c9Erst9Z8KEUgvsHUTOKWe/dXnW Pxz4ElQdITXOoV9R9XuaTuMqPFoXAAcbNLY4IEMJcSCEtzh8A5bz2bYHQA+v7AQGhdOR OjoDDoJjo24zT7zNaI0kU3KvFq1VswrfOhjTEjUcw5t3Q4kK5kWY7mjUe2gNbuEM0JqY nc0znovkLradG9t2C6cKwUaylR3iUfwgd/ykNuHhuRzxWm5pcvMXlaWnIwHzaTZWpfPz XBsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T+vYmI8M; 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 l7si18962980plg.222.2019.05.20.05.50.37; Mon, 20 May 2019 05:50:52 -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; dkim=pass header.i=@kernel.org header.s=default header.b=T+vYmI8M; 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 S2387854AbfETMWM (ORCPT + 99 others); Mon, 20 May 2019 08:22:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:36056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387846AbfETMWH (ORCPT ); Mon, 20 May 2019 08:22:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 956C421019; Mon, 20 May 2019 12:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354927; bh=qFmpTGVLbRz4mBAxDSw8NvsVt8gaTA3Jkk/yCGfbfOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T+vYmI8MIREEDV/D/I1/PAj8KjVpkAq7+xXjFFH100czZLvYDqKoNJkTJB/CI0mDu 6KvX6k5gUFJ+2ULUA3WHmvhcPlkvJSYRjc+8stwhuG5jkM5PmhAyncgaUAKe3ZzcXZ t9vpUBl0gTQg51jlZHwOL6selaZzh0LjnXKmXQLw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Herbert Xu Subject: [PATCH 4.19 031/105] crypto: arm64/aes-neonbs - dont access already-freed walk.iv Date: Mon, 20 May 2019 14:13:37 +0200 Message-Id: <20190520115249.201384561@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115247.060821231@linuxfoundation.org> References: <20190520115247.060821231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers commit 4a8108b70508df0b6c4ffa4a3974dab93dcbe851 upstream. If the user-provided IV needs to be aligned to the algorithm's alignmask, then skcipher_walk_virt() copies the IV into a new aligned buffer walk.iv. But skcipher_walk_virt() can fail afterwards, and then if the caller unconditionally accesses walk.iv, it's a use-after-free. xts-aes-neonbs doesn't set an alignmask, so currently it isn't affected by this despite unconditionally accessing walk.iv. However this is more subtle than desired, and unconditionally accessing walk.iv has caused a real problem in other algorithms. Thus, update xts-aes-neonbs to start checking the return value of skcipher_walk_virt(). Fixes: 1abee99eafab ("crypto: arm64/aes - reimplement bit-sliced ARM/NEON implementation for arm64") Cc: # v4.11+ Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/arm64/crypto/aes-neonbs-glue.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/arm64/crypto/aes-neonbs-glue.c +++ b/arch/arm64/crypto/aes-neonbs-glue.c @@ -304,6 +304,8 @@ static int __xts_crypt(struct skcipher_r int err; err = skcipher_walk_virt(&walk, req, false); + if (err) + return err; kernel_neon_begin(); neon_aes_ecb_encrypt(walk.iv, walk.iv, ctx->twkey, ctx->key.rounds, 1);