Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp104642yba; Mon, 20 May 2019 05:47:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/0pd7LBAnSi3YmzbgHm4EE0q2u0bTr/+WliuKwE53fpwbQo5PW5h0rqbSchhLLhDlo3WD X-Received: by 2002:a17:902:108a:: with SMTP id c10mr76180705pla.48.1558356459004; Mon, 20 May 2019 05:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356458; cv=none; d=google.com; s=arc-20160816; b=lzf9Y34NgTfkqNg+RjlHENKquOyOFeszn9edUDRUs0hVU/2lsK+nP3pW6q+LmZl77G nLuVOMrPGalPptt2WNChJA1m+AsuojtGThZGeQ/mdctL+j9D7mHiWMdYbM3qZOXqJNUx gNzaPMkJcY8a2ChSjD/xKT2nkX7lR9w8sv3HlqWDKdKDoQ/R2X/6IJZq/zcuJgflM5Nx 2Kc1VBsbQwFiCm4/0kEyMneBPTzWl3YznpU/hHWvs3qiNvkRk2LBUBVVCSnSAxdOXGfZ jycpJt/6krfsxmtNFWMi1RqzRZK46BJHYGA9umxCG8vO3/yt3yOd1Cxy3P3zSwkjzlqW U1xg== 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=qGU0Sr0EdQOKS9GzxYs6NCeCps4oF2ONbpIq6PEBS9c=; b=RGKV0MQ+vx8+mRwewlN7KfSnIj71BJXFXmaoOOVFTiCwdHv/N9LO5ZERZKcKLCXmLg ACh/L/gxG4WLsrlPi0gILEEnP5JQz0lzcypbK6iON0UfkkEj/+AMDtodVIOo7prRxk6B 1prTx0y1iToQPVKa4sq6Bic7Y5iJbiRgFhsEIV1dzCcqqt5fbk/xQZbmkKHBkS294nXi RlhQJhvD37K7L+kCjnTFpWWie7X1w/pYXBJIor9xXEoq1wtgayc49EbChcfQUXo2LBFX psOVNeX4BOXUm3TChU/3GIp1NVkzmsNhthyuNRGr/ep7OySuHeo1CoMOlJQSoxl2+0br h4Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qn8gG3jv; 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 204si3614899pga.373.2019.05.20.05.47.24; Mon, 20 May 2019 05:47:38 -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=qn8gG3jv; 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 S2391484AbfETMpn (ORCPT + 99 others); Mon, 20 May 2019 08:45:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:41990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388920AbfETM0e (ORCPT ); Mon, 20 May 2019 08:26:34 -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 6AD2D20645; Mon, 20 May 2019 12:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355193; bh=rmffEHAhueVbENrjSXU8HS106ZhLz6ZVTjAObWH7Cp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qn8gG3jvLTEFlyaFJ9DdhrcZlmWwsYLqwewLZwpkRYmf/ti/EHoFhW4+89AqM0i9u neYa9Lwzh4aCQHMJu0psHkCCuKew3EP8Q+quAdECFdoEfF0S9MejkOZ37YArPPdVHK B7d6AjOXn8ni97vAm9Ij3QvHAdK0n6ZQpwmd3JJw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Herbert Xu Subject: [PATCH 5.0 027/123] crypto: salsa20 - dont access already-freed walk.iv Date: Mon, 20 May 2019 14:13:27 +0200 Message-Id: <20190520115246.604854229@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@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, false); - salsa20_init(state, ctx, walk.iv); + salsa20_init(state, ctx, req->iv); while (walk.nbytes > 0) { unsigned int nbytes = walk.nbytes;