From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389201; b=iLcdsDJ6rTkzzL3aHJdMCWJRJQNBOM5XO9DVm7xmfcEMClurrMIttWGdiNP5uYjGlVXf HB6ShqV8V4dllyPwaAzPWYgMrJqsRclVZcgkiounmcahWQwNi8yZ/WmNdM0NatTVHleDZ Ynik8jXvVnzq36K0N9yYQZLPV2flMGGvV9WxUYCuAItXyShWHtL9ikg30xKttp12awhEU 07jBhshPmSxj0djO/o3rbm7OczxVN2R6atcawG6I+BHZm9x5oViFwRLWIbYIVzN0XMaHf w3j8BEUk+VXwYTmmzpAqzMP54YWx3pWjSEJ9mQ3STCd7wP6Nm+nShYrzzBvG+7TxW2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389201; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=cxtB2OloqIlR2Y9HlMIz+eMec5mtG52AqEuqRJj3M3g=; b=onr7RxsPDCBY2n7ndRZ2JlJOgZ0x8tcGJvCRjEVk5tGYZZCpN4muASg/zineYhYdLwOS SBY/IG6GDhHigVbAP5yvfstQm1s8Puuh0AxGakuNNPc1hyaS7rDEa7pJaMPV/bWOZ0Qv8 RiwVyexAYNJKK+3RWqfEhAfGuEnkTn0fjmI9SoofGWeJBPt0FclYGrvo6trddJzsVEp5e zgyU41yrEEL6zjZIhYsiyJ7ftixT8kGVfMcyKJYCoLJXALTUuTqFqn8+/7d1rYZsrUoAd 7flphtJr03n6COyDHjpwt3VRZDEqr/qPQHHIP+KhNsCFR/BXraCQjyg3rsVE0Lnuaqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=X7+eAK4l; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7394606A32C; Fri, 4 Dec 2026 13:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=X7+eAK4l Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBC3C1F00897; Fri, 4 Dec 2026 13:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389201; bh=cxtB2OloqIlR2Y9HlMIz+eMec5mtG52AqEuqRJj3M3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X7+eAK4lRQrMHuFpIZU4tNoSzOK2mj18K1OAj3PfrR9PxctI5Gzcwkb1HPi45fBwM 00pLO/d0eHo1kI8kksRrIlchrhOh5+fgy0HweFH1VF9s9BvUSPnnAhsOoL4WD42zhZ IZpnyktLhuYttPuJWOSh2XdAO661i0VbvyXTvVng= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Perry Yuan , Yifan Zhang , Alex Deucher Subject: [PATCH 6.1 0903/1059] drm/amdkfd: check CRIU SVM priv data bounds before allocating Date: Fri, 4 Dec 2026 19:07:14 +0900 Message-ID: <20261204100707.406448947@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Perry Yuan commit 732239b002678d8c534503f52a16afc310095523 upstream. kfd_criu_restore_svm() allocated the per-range metadata before checking that the range fits in the user supplied private data buffer, so an out of range offset cost a pointless kzalloc()/kfree() round trip. Do the bounds check first and return -EINVAL directly. v2: - split the original patch into two, one change per patch (Yifan) Signed-off-by: Perry Yuan Reviewed-by: Yifan Zhang Signed-off-by: Alex Deucher (cherry picked from commit 0c3caec1161e458092364cb448e5bd165a26dcdb) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -3814,15 +3814,14 @@ int kfd_criu_restore_svm(struct kfd_proc svm_priv_data_size = sizeof(struct kfd_criu_svm_range_priv_data) + svm_attrs_size; + if (*priv_data_offset + svm_priv_data_size > max_priv_data_size) + return -EINVAL; + criu_svm_md = kzalloc(svm_object_md_size, GFP_KERNEL); if (!criu_svm_md) { pr_err("failed to allocate memory to store svm metadata\n"); return -ENOMEM; } - if (*priv_data_offset + svm_priv_data_size > max_priv_data_size) { - ret = -EINVAL; - goto exit; - } ret = copy_from_user(&criu_svm_md->data, user_priv_ptr + *priv_data_offset, svm_priv_data_size);