Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2452893ybi; Sun, 9 Jun 2019 12:09:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4i82bfnTZihfT5A00CyCwsW3d7CBZNhmLE8zOMQv1a2vIzpWmxzja8UK6hA4euXXSyrle X-Received: by 2002:a63:ec02:: with SMTP id j2mr12946350pgh.340.1560107381580; Sun, 09 Jun 2019 12:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560107381; cv=none; d=google.com; s=arc-20160816; b=Q9lz0DHapVvtNb70vt4kJABbeXUV4NC5ipCnJtLuaSwQwefMV+HRujpJDFD+n//M+R BX4D/0hxIKqitCnpevHK81TIZQNu2F5zJMCoUxnFmxHMEdRBnTWu3e4Bfsk7BhUdpyw9 xQBzvi4h3Mh7jF2mg3fwUlF3lt3W7qO9C9b9TucVDBfJ9J0qF2Z9ZDmXddPqxjfDrZEq SYex6ub4K5mVLmggWSJvvlvQWG4tm3ljkVB1B1e+S6M94EsZjVp1UGd5oMF+xzlcOwQq iaWnJKl7jwEo2Daq+Ey2REriFuNhFAidPx1SZEKNIDuyeSsb4CKPqkRbFB9rkvW3OL/V YzfQ== 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=Q0HvbZuH7BAvvM4+ur1OEBBxUGfRmlXFZur+UvfNg6zT3heRREp0wK/Y0UKmSJ/d6u a6Z3pDPzxlsz2em2LG1kcAfgLzJhzHF+gzdI0sVJzEaDiu91Xdv7GJKS14C4+b4wJ1r2 iwqfeQEifsL5LixOeBXH5BB4onDQKUEDeY7e7mEq2xV+ZOJUURbuv6gUV8GmKS/Sx6+C zRq7Q+2uTejQTBb86EbPO6GjSA8IqbA+nzFWtYFCaAe0G+IitHPmH+lJAyvJL7IFLpzN NuARHxr61NmDgIntwIqXzNkqW48pLWUC9W+uYyBQPE2gcKfmBgfwtBctpavjBbAKWP4i o73w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mXFJ+79L; 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 o3si7571675plk.167.2019.06.09.12.09.25; Sun, 09 Jun 2019 12:09:41 -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=mXFJ+79L; 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 S1733008AbfFIQ4e (ORCPT + 99 others); Sun, 9 Jun 2019 12:56:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:59096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732614AbfFIQ4c (ORCPT ); Sun, 9 Jun 2019 12:56:32 -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 D8E86206C3; Sun, 9 Jun 2019 16:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099391; bh=SJ3bvGNHGX5MTf8QAP45iUrPWgiuSOwtd791qLhdx14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mXFJ+79LUTqht0y4qHv4KZl8nmDyXBfYaYI+zM+ogXbMjRiPvs+NfKH9C1k8MERsP zErDyQ1ekx9SGU6ohlArHi3KjlN0vrcWlJNjP7LAMkT49nsKzE8v8sN8Q68YagPf36 FSysoM1F9YhdAVjh+z4KSjr12+c6SWAwxnCGyncU= 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.4 025/241] crypto: salsa20 - dont access already-freed walk.iv Date: Sun, 9 Jun 2019 18:39:27 +0200 Message-Id: <20190609164148.506134155@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164147.729157653@linuxfoundation.org> References: <20190609164147.729157653@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,