From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 437541ADC83; Mon, 4 May 2026 14:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903524; cv=none; b=hnA/Vk++lTEQ5JO4a9p8gIw/zAfNtRFj8qoEn+KHiDIld1ZzAgphArEwNLwcSsLnX9ZGucRXR0CnvRtLyfT/XJer2CNOPMvZ8hw4zMSfaR5hm/3iLVD3NHbl+w+x4IH+UW80WXZZ/JV6skvrFov2tGwjsBbewfkYqr2z+bKiXfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777903524; c=relaxed/simple; bh=2k8NHulTkJVvY6x+ay+1PhnV/kJRQlmuwx+6302w6oo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ChQDwvU2dtG7uM37/N7MvcQiztn8sN/hk19gQTcyyilNHXF4hwN59eSjdjqOQkJJd9d7uQvM9Bgx6MPA6ozL7ZyFeK4a5bkrwOLlOnL2Su0kJQNgzEhZFXX8sKqOhQSRsdlRaa0iW5VhIlV3W6UC5YSItdvKtMt+0vneuk5PS1g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Y/h+p/nU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Y/h+p/nU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC996C2BCB8; Mon, 4 May 2026 14:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777903524; bh=2k8NHulTkJVvY6x+ay+1PhnV/kJRQlmuwx+6302w6oo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/h+p/nUnKelyxrm8kcStpdKXY0V6fxrmnAypcF6TXykx8PbC3CpBi4uHxPaMLVc1 WIFqXgu2za0gA3LIbVszwv/RWWgQ2NOa8mNsINrr2Jpn/sEzSjOw05eEPnm1hHGgT7 yc7FefSHXFgE0r3FUwfxgIWqymfNHsjyW3PX7bB0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thorsten Blum , Herbert Xu Subject: [PATCH 7.0 267/307] crypto: nx - fix bounce buffer leaks in nx842_crypto_{alloc,free}_ctx Date: Mon, 4 May 2026 15:52:32 +0200 Message-ID: <20260504135152.856024696@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504135142.814938198@linuxfoundation.org> References: <20260504135142.814938198@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thorsten Blum commit adb3faf2db1a66d0f015b44ac909a32dfc7f2f9c upstream. The bounce buffers are allocated with __get_free_pages() using BOUNCE_BUFFER_ORDER (order 2 = 4 pages), but both the allocation error path and nx842_crypto_free_ctx() release the buffers with free_page(). Use free_pages() with the matching order instead. Fixes: ed70b479c2c0 ("crypto: nx - add hardware 842 crypto comp alg") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/nx/nx-842.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/crypto/nx/nx-842.c +++ b/drivers/crypto/nx/nx-842.c @@ -116,8 +116,8 @@ void *nx842_crypto_alloc_ctx(struct nx84 ctx->dbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER); if (!ctx->wmem || !ctx->sbounce || !ctx->dbounce) { kfree(ctx->wmem); - free_page((unsigned long)ctx->sbounce); - free_page((unsigned long)ctx->dbounce); + free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); + free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); kfree(ctx); return ERR_PTR(-ENOMEM); } @@ -131,8 +131,8 @@ void nx842_crypto_free_ctx(void *p) struct nx842_crypto_ctx *ctx = p; kfree(ctx->wmem); - free_page((unsigned long)ctx->sbounce); - free_page((unsigned long)ctx->dbounce); + free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); + free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); } EXPORT_SYMBOL_GPL(nx842_crypto_free_ctx);