Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp82505yba; Mon, 20 May 2019 05:24:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjl1lCF/lCBkT/u+xHf8yBpDdEeR1eCkq7KLkYkGaCNmONIhIPkPjyPQETMjPAWbxAfV8H X-Received: by 2002:a62:82c1:: with SMTP id w184mr49467217pfd.171.1558355042538; Mon, 20 May 2019 05:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355042; cv=none; d=google.com; s=arc-20160816; b=iZhkeF8hFYpL9TQPM4uIE36AfhaV5v5JUq3QBdyXqYnP79UCnVIzHFaF69T8B/x1mp GDesO4STujoz3UA8Dxm7ZqXqocRGCiLSWaxxbmtExoiBh1QoDppaWgtV2pXtQyejxg1z rxrcUmtNcvqOH1DsRp1SBg6+Qb+DpIFHd+gRARF+tZhSf/LMQSg8xLppn6xF4H9epxXt Dhr15DMTAALc7SHFB5PHlHOYaUolHESaU8I5K0Z45zca30krHxltM+M3UaDcDV4yeikb EthR+gzN4Z90RLkJNRc2/cEsO6mpfXpWS0YTcnK0Yl6re4USLPOZrx0NYsH5iTLnVq24 bPOA== 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=9/XG7LR5dVW836QgD9aYgNeLSjpfoOQdhXy7Wio1Uqg=; b=t62bVZq8fKUMbk44C/umTq2gniiFN/dZ7LVFlcctSIkagMB7DMKBCfQlb2kIUYkr3D COSBl7JQ62oiuAx5orXqi2TPuq9IGUq0YjeIIejnzbtF7ifk16qEPHNSsCTUeWvpc11z lUW0aTg3XtecpjlCZOm1/HSfZdUELfzbuq8f7A2JIsLuFkfU02byXu0qV8DNzMKtH54Y /ot019d77C1v5ZZn/jgGI1VXo7Pc8ckXJL/eVpL86imGuOFnlYcz/5tWoWB1exhSjhZc 3Kn1C9eerScTs+G1i5ZX2pTOARaW8bQztp1ExK1KUflbP6bfBfcJvK4z+S3ZAQzCg5e2 E2Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cJeF2kK0; 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 g3si11659173pgq.247.2019.05.20.05.23.48; Mon, 20 May 2019 05:24:02 -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=cJeF2kK0; 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 S2388342AbfETMWJ (ORCPT + 99 others); Mon, 20 May 2019 08:22:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:36024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387507AbfETMWF (ORCPT ); Mon, 20 May 2019 08:22:05 -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 0E9C4216E3; Mon, 20 May 2019 12:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354924; bh=e0wQ/Or/KATeiOfZ/Wp3Ts3mjkNeCXdisU7ebNssEb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJeF2kK0z4WsIdm9vEiZdGd98EolgVK1UjK3P+8G8DK4UUmXKwFAvy/h2CRVp681D 1T6+DEH8koc3NEMJSlTxWb1HDaeJiAgSreU4IqKlN2qZU0z+Y1CiRlEUdu7bys+G4W Nj8NFqV+4N6aYKJR13/mHmTqUk512gQjhKryNgp4= 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 030/105] crypto: arm/aes-neonbs - dont access already-freed walk.iv Date: Mon, 20 May 2019 14:13:36 +0200 Message-Id: <20190520115249.126168343@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 767f015ea0b7ab9d60432ff6cd06b664fd71f50f 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. arm32 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 it was actually broken prior to the alignmask being removed by commit cc477bf64573 ("crypto: arm/aes - replace bit-sliced OpenSSL NEON code"). Thus, update xts-aes-neonbs to start checking the return value of skcipher_walk_virt(). Fixes: e4e7f10bfc40 ("ARM: add support for bit sliced AES using NEON instructions") Cc: # v3.13+ Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/arm/crypto/aes-neonbs-glue.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/arm/crypto/aes-neonbs-glue.c +++ b/arch/arm/crypto/aes-neonbs-glue.c @@ -278,6 +278,8 @@ static int __xts_crypt(struct skcipher_r int err; err = skcipher_walk_virt(&walk, req, true); + if (err) + return err; crypto_cipher_encrypt_one(ctx->tweak_tfm, walk.iv, walk.iv);