Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp79585yba; Mon, 20 May 2019 05:20:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIBtDPcAh6mAF59kq9yCcGyJGV+1RbZCgKrJJrgdZeF47xfD1lVQJSAhI1bnlqxbSQ4sKL X-Received: by 2002:a17:902:8ec3:: with SMTP id x3mr20888715plo.340.1558354853045; Mon, 20 May 2019 05:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558354853; cv=none; d=google.com; s=arc-20160816; b=okgo0GKFILwyN1glF4tiv7ElpCAtSl2Hsv7GB9v83jzCsvhGZjUhUvyyEuaYeXAvvr Pjgv6To6wokWeWY1zxN/VTyw3iwKUmrDzo2b9xy0AwBU3OzMhS5sdH1KK6eBq8fpT4aq JxVmWzWIwnSnV4XBcihuftNhXLq4lFPEOehsyMktTcOOHt3FejM0rFcRGbTVxx8xC7op inJ/yvZdMJRhIyym+NYC1AixhOd9NmSRK6SK+LNqLyvi27r+JUJLCI9HPYL2xqUiZzpH 5CUvDW23CwobFaEs0pExLOygzXt8h+lPr8hTi0S1ebglAEfHg4/p6SL2TWBkP+RhsLSA 78nQ== 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=3vomRrRSjDv+iPqORRdPsgmyxKb6ze2rS3zTBptHEp8=; b=mldzfRRX0GSFbA9yZA95uXdGEJOqqEGZBOTD2Dhm35Ek9iLrHn6GMJYBwZ88itJi53 CjQr3VyCNqOJF+SNKJYNgZhWr6dB3aO7y+gL/E5di2ORpeEkPYVpbmbisLGzYcMMX9Fx Z++hoyzXDVtP3UdOebV3uqkXKLpRfBLrlwETmXCZdyWUMEjCp4lBfHT0Mgul+FqCkvGw 7ZI015XAqE442vhHFqw/xb/iOkec1trAc3DfxJul6SsN+VEt+KxvqgldH1GZIn/P813I yYBtnrQ6FbIpsTIQ/dQDL6ZQI2z5O4SwaQUW1QkZG2OvYPXEPOA6Rdkd0QiTwjmRV8VI cBBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gy6HOmiL; 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 bc7si2666468plb.108.2019.05.20.05.20.38; Mon, 20 May 2019 05:20:53 -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=Gy6HOmiL; 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 S2387557AbfETMR1 (ORCPT + 99 others); Mon, 20 May 2019 08:17:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:58414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387523AbfETMR0 (ORCPT ); Mon, 20 May 2019 08:17:26 -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 F2E1920815; Mon, 20 May 2019 12:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354645; bh=SJ3bvGNHGX5MTf8QAP45iUrPWgiuSOwtd791qLhdx14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gy6HOmiLUgPH3WsM/dnjDNx2RpSLXAs/NRq183hLfNH4pTyhI4OLntcGLHsBiWG/B zPeGyB0jhGnp8RhH7mxYQFgyKI2cY7LwKmaZXkjS8bkd/Wxrj+DvpZDgkvtSOon5k3 LwvRlf3ogMI8D+GSZh9QQ/pEn3qZVfihM7kevmOY= 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.9 36/44] crypto: salsa20 - dont access already-freed walk.iv Date: Mon, 20 May 2019 14:14:25 +0200 Message-Id: <20190520115235.316656833@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115230.720347034@linuxfoundation.org> References: <20190520115230.720347034@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 @@ -186,7 +186,7 @@ static int encrypt(struct blkcipher_desc blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt_block(desc, &walk, 64); - salsa20_ivsetup(ctx, walk.iv); + salsa20_ivsetup(ctx, desc->info); while (walk.nbytes >= 64) { salsa20_encrypt_bytes(ctx, walk.dst.virt.addr,