Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp107989yba; Mon, 20 May 2019 05:51:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx93isokXVJW3aGfLE9oNklyzYeL0MIFR0nMYud318cWVPhhfTGb12mXcBK6ZBOl0eQ0YDW X-Received: by 2002:a17:902:1021:: with SMTP id b30mr36968575pla.324.1558356687738; Mon, 20 May 2019 05:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356687; cv=none; d=google.com; s=arc-20160816; b=jIXf5gT8PyPWHo2VMKVjzweh/ojEibve6xypO1vebHrrLQBfCLmDQuPb0pTlaHMX96 niXFN/2DenXWBbxxbZp4SNbPqeoYqKR5a/1YM+eDbfjA+cSwH/bBjVd/2ePnkHouRpaZ B64U4jJH8sHxa0higth3e7xz2dq1mAqcYWREcb+49QU3+CoRNXGJ/dzb0iQJO8YtBSR/ ei4ryc/Dr4QomKFw5B223mtfwgBqGss7T3hf6fs31uoG5y8G8eu8y3aduHXgTD94CmxO urbDMfwrIS/AeVEdLeAl5kzpECZ7k/53NmqO4wmM9JurTNAiSBgED/wBYTxJExzZFbQp KKvg== 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=W+Lm7tovo41yGFSnBATQ5OmAuB5kRrRGeGUoP50MCnE=; b=e6vklKlnCItVEQoEXLZMH4Y6t9U57N4vRY7U5PPcMvk9P6vvB3x9YnSpMWWF+Qsa0w Vs7DJvtxq5p0K0QLjdqIuNqAUfQyVzrRRijI65ysdbjVEOJJF98LH1n/MFZ2wi8oUJ/x ruEJBxDe2tMkCgCtVlGXwJVvIS8emsjYrBsTX6sDxnrnilSQyT3b5vPnUnmroVLy0urT olok8yneZZrFu41rbB/hfL1Um4ANWZDhHqEzC7fPopWgUhsD0QpSpmYc56lv7pDmAK5V MsNWvQX0odBpS1fmT6nIAhoS6CxyPHqykaiML+dh7hpEgwbjv0VTg/bOP+8OPEZBXmcd o8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="k8qYiIw/"; 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 r142si3808334pfr.2.2019.05.20.05.51.12; Mon, 20 May 2019 05:51:27 -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="k8qYiIw/"; 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 S2389155AbfETMtc (ORCPT + 99 others); Mon, 20 May 2019 08:49:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:35364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388196AbfETMVf (ORCPT ); Mon, 20 May 2019 08:21:35 -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 96D0F214DA; Mon, 20 May 2019 12:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354895; bh=iVm8FVhzSjc67LGrX5HDsQyAxRaS8C+6UytUP01HyhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k8qYiIw/58MBz93nmfP8luWj2fTw5civan1jv1KIZsGIm2SQzHhPrApNpUGN0j9UB jKNBePlnO0ia1wVsTJ3GLs3RVI+3vI7riJ8lEtS8rIKTCSbwZ7U0uv7OIZVu5f2oA8 CfXtqNM8zRP5QLnM+bM/Mc0+BcdefBGW66udXmik= 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 020/105] crypto: salsa20 - dont access already-freed walk.iv Date: Mon, 20 May 2019 14:13:26 +0200 Message-Id: <20190520115248.416824052@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 edaf28e996af69222b2cb40455dbb5459c2b875a 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. salsa20-generic 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 b62b3db76f73 ("crypto: salsa20-generic - cleanup and convert to skcipher API"). Since salsa20-generic does not update the IV and does not need any IV alignment, update it to use req->iv instead of walk.iv. Fixes: 2407d60872dd ("[CRYPTO] salsa20: Salsa20 stream cipher") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/salsa20_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/crypto/salsa20_generic.c +++ b/crypto/salsa20_generic.c @@ -161,7 +161,7 @@ static int salsa20_crypt(struct skcipher err = skcipher_walk_virt(&walk, req, true); - salsa20_init(state, ctx, walk.iv); + salsa20_init(state, ctx, req->iv); while (walk.nbytes > 0) { unsigned int nbytes = walk.nbytes;