Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp141826pxb; Mon, 13 Sep 2021 15:19:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW7K4976K7LumUakNBCsGc8IFSYFQ+Uq74QD2sZ/bRRL02b7yM9kePes8vWchTrw1+E+4v X-Received: by 2002:a05:6e02:178d:: with SMTP id y13mr9298192ilu.266.1631571564468; Mon, 13 Sep 2021 15:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631571564; cv=none; d=google.com; s=arc-20160816; b=ERdrz2GxW1sxZyM85TejOzZ4eQAX9rbb3xqvyQTC90OtDiWmVX/PF+ptvBfFfkUAIo hS6RxMeCGmGa/T1sn7SQB2Yf6G6azI1UlMxpPHDL8a/jOzEnnzbviWYoW6ZaKpucrUO6 JCBdm998ff/MHNiiNX0R5zE4w6iNgTKZSorqZbc3smqtWKaAsXX75YWEnv4fR2zjnuYj 7sUxSw8iM789FbSMFdw1pko0EzZc5M94RxGLHLm+IoK3yChm99Jtjp9LyHlUvAJhCmEc d5ABPr2Qpu+SOjA4os+kS/nrThUq+VOTGxtRpexv/qydhYkwRo137+KP0FTY+MPrc79t l+Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=04+wGiDvtuDCBG/FEquoQAV0okAXChKPKb2+t9D4hg8=; b=XnzKXAGEvlwQ3CPJ/99mxDUSo5BoVdULutEGW0q2fijzIKfhYC8CetBj6ZU1hwLKqq 6hxyZXSBwIMwaplkQ1SwOwi6A9Sm4FDLxCLlqNDiXbEQXD5R6ijyCytE7qMeTDLLAcjd SC32qTYe45qn8y4Wp1YrQ3tBQcUZcUEFSL5w7RhDowaHmIwxUIKHD2vqg1IfUVUfSgPf DEOwwBH1C+Y3XSxIhtbwdpfOmgxYFoJeYMb6VBLrIqProBX0iE0+b/GSOg/K8FRCSAUY EzOkqZ7YuZKQ8atczwoHvbauCVNyEBu7K0qqAZIx+EWNWRCndQ+pJupUrg3VQsXIwhqn ayjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a4eohUnw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r131si8262050ior.19.2021.09.13.15.18.54; Mon, 13 Sep 2021 15:19:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=a4eohUnw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245010AbhIMN6y (ORCPT + 99 others); Mon, 13 Sep 2021 09:58:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:36594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343610AbhIMNzr (ORCPT ); Mon, 13 Sep 2021 09:55:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1ABB6613AD; Mon, 13 Sep 2021 13:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540155; bh=xqA451Gq5eHVww4O97l3wIjinDAwalyeCfv3LaE39KA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a4eohUnwLQYUsGSQlKFOsq08EaHf226Ipg0zZZz5DrWhIyIF9XPOyoJAxcDI7pCZu C+IrHkqM/L2nKebJRhLnEFqH7F6H6kAyjLOqDdetPtjX5ZaAKgrI8d198JhZDtzHo/ C+UOTZQD7SH1/ypxMUCjCIHv0CfArQWYX5vUYLWU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Jens Axboe , Sasha Levin Subject: [PATCH 5.13 074/300] blk-crypto: fix check for too-large dun_bytes Date: Mon, 13 Sep 2021 15:12:15 +0200 Message-Id: <20210913131111.852007008@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers [ Upstream commit cc40b7225151f611ef837f6403cfaeadc7af214a ] dun_bytes needs to be less than or equal to the IV size of the encryption mode, not just less than or equal to BLK_CRYPTO_MAX_IV_SIZE. Currently this doesn't matter since blk_crypto_init_key() is never actually passed invalid values, but we might as well fix this. Fixes: a892c8d52c02 ("block: Inline encryption support for blk-mq") Signed-off-by: Eric Biggers Link: https://lore.kernel.org/r/20210825055918.51975-1-ebiggers@kernel.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-crypto.c b/block/blk-crypto.c index c5bdaafffa29..103c2e2d50d6 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -332,7 +332,7 @@ int blk_crypto_init_key(struct blk_crypto_key *blk_key, const u8 *raw_key, if (mode->keysize == 0) return -EINVAL; - if (dun_bytes == 0 || dun_bytes > BLK_CRYPTO_MAX_IV_SIZE) + if (dun_bytes == 0 || dun_bytes > mode->ivsize) return -EINVAL; if (!is_power_of_2(data_unit_size)) -- 2.30.2