Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4823224pxj; Wed, 12 May 2021 14:10:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5RaiB6580/HZGNXrIIkhqfgWZBXqJZWWXxcDTFkkgPQlV8xsdAIm+sWKih8G1/PZGn3qu X-Received: by 2002:a17:906:26d3:: with SMTP id u19mr40573328ejc.128.1620853834988; Wed, 12 May 2021 14:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620853834; cv=none; d=google.com; s=arc-20160816; b=EzzsW08JIxAuOSP1+RYGY3DrjkrjnsVJpse7khly7hTfDHSvftEu9WEou0uYCt955c rYMXDlKQmnEZAsIkfX6cqJGF0/M6cuXt8Q5YFp3cqPsRigk185hpDBvhRsrH6Wokb0E2 HovU7saYSI2finbz6DLQlsORboLgOmcpEPPepTd6aeTBBlngiYvkQxxludPbTfjm3Sv8 2tx0yRqqntWID2P8UNGJNgQEBH7DE6NsWsd1dxVmcPA8gs3/VtZ2oLvG+leMJHg5vXue eJhNiPru2MGLSC04uCpJqr9j+NonXSzRv37yCr2Welq7EnErjJDh+X1PwyUA33qBEfSD 9SmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2UTfPZadZvSwn8+sNIKhid9S9bN7vQkfzne7oY6O0aI=; b=v5cKQv5fPdtPynMZrjtVV1Zr7HOwsFQxB21TBiXIzTlssgY4TJHJ2rmJS7y5ITeoj/ +QUGT3MzVXPR3b1dth1y2y6NRfEPdDBHFsnuoTNe5WXI0DzEHYrDAID7QFw8+TbORmhh 6pYf9dsXUI7OKNAfFsfwfUZYpH12QHwwrTvB3UqPyYArx7xUHSkcb/XPFJ2u9mzJN/o7 VJcTxNm9zGgPCLXGOq7wv4Dd4gJxEtPcidLNXb5QnY643xhxtbz0ExYHwLbGF3F5cjo3 VO06zc7shbUux/nQrytTx7pWtLUeJuknVbRcggy6VZ7YoZuiCHqpuAUkFCLsjg9Y0del Lbtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=inc5AvJg; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qh7si53296ejb.11.2021.05.12.14.09.58; Wed, 12 May 2021 14:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=inc5AvJg; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237322AbhELVIH (ORCPT + 99 others); Wed, 12 May 2021 17:08:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384947AbhELUFr (ORCPT ); Wed, 12 May 2021 16:05:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07D4C613FB; Wed, 12 May 2021 20:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620849879; bh=KV/kbZd31J8snv17/g8BAEhBEHm7mAyytVKpZqg3zA0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=inc5AvJgcd9lavh0t/B/EzghYuDxnl7fL46NWCRgeeCX+fOBqrignfUptxNfGL8Eh YA5AEAHGbu6swO4mKkEiDRp3WZDo8PZ93qISy+1i2oQh31ZRIGxg+Na0rZIMdoPck4 UD2VaiKq+YFruaRas2sSuAjUngZ34OgFXJW4yJJoRitM3lrB1EkF+inxNwBIZlw7TS 6PA7XQaTN4ejeor5yFGLR5cZFI+ssWDJS5HkZQdnMUL48eMC7feJuW8MUzpvJubK4Z bqAGPhrGSSxM2bALvhos0Ek6JRJFszpGFDGj3y+kr4lNCZC3qYnXJfKN4+0w2TlGj2 2fQr64TW/u7Kw== Date: Wed, 12 May 2021 13:04:37 -0700 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, herbert@gondor.apana.org.au, will@kernel.org, kernel-team@android.com Subject: Re: [PATCH v3 1/7] crypto: handle zero sized AEAD inputs correctly Message-ID: References: <20210512184439.8778-1-ardb@kernel.org> <20210512184439.8778-2-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210512184439.8778-2-ardb@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, May 12, 2021 at 08:44:33PM +0200, Ard Biesheuvel wrote: > There are corner cases where skcipher_walk_aead_[en|de]crypt() may be > invoked with a zero sized input, which is not rejected by the walker > code, but results in the skcipher_walk structure to not be fully > initialized. This will leave stale values in its page and buffer > members, which will be subsequently passed to kfree() or free_page() by > skcipher_walk_done(), resulting in a crash if those routines fail to > identify them as in valid inputs. > > Fix this by setting page and buffer to NULL even if the size of the > input is zero. > > Signed-off-by: Ard Biesheuvel Is this fixing an existing bug, or only a bug that got exposed by this patchset? It would be helpful to make that clear (and if it fixes an existing bug, include a Fixes tag). Also, skcipher_walk_virt() doesn't set page and buffer to NULL, as it is currently expected that skcipher_walk_done() is only called when walk.nbytes != 0. Is something different for skcipher_walk_aead_[en|de]crypt()? - Eric