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=1796380722; b=bW20B9w9bS3xHLbOvQMwzPfhUW3jLfC/8K+jPDIWcGqKRBHpDaJtVShWw1eEGKzZZ7D3 akNlBRq9rEFaNLeA5fFj9bERXnOge7U9QIDIDzoiRGym6+YovA1rPUKGgKge3gehuIAkz capE3kMi03f4f2GPJiZcDl4q5DlKNjAXjDCDko8XW/83PCe2MnnZ6cVL0+2FdtmHFqxHW muHnTPgC35Idm8HfaWpGxPqxYb7T2XZNEkLqeWJLNdOHEN2BcixSpQUqVbzCHx2cOm3Wd GFHPXPseMWaN5CcS9RXxZaeXvZqm/2QjYCEChuK0+ov+RxOKvTsBHl8i3V9EW2+TWnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380722; 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=FPMUi4fT8Mm034JGqMn+jXYwkzY2cATW01TIqXSQUks=; b=QarfPV7tf2thtiNHEL2YrbhF04NJemk68bBINIHr/K3ZP7sF5zo+ONKJ6V7+RNQNN2VT 1FdyRigI4HX7Aal257LQ1skwAFH0WS0/5w7s4NGGdPw/kM0XjIYccT+u5Mlu63/LmeGOq ffzsUV1/o970Jq2ivIMeFdPDx7fTeI6cqlyNsC+zv+a+k8LA5LVPngnRbOx+RkSxZXXm9 V1DSFTaJzx/aBiJx8xBsRSM2wAIMkcXJwklEIXRL5eDg53UGx/VwqVNBxX0q1OwSTVR3X 9rDRxLO3VtpoKHJtU2jduSBD+CXoYeG6MtczbjmVGQbHRQmSGyAcmgcgsgZbKm7R/Qg== 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=Iy7k+NXR; 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 BB220606A322; Fri, 4 Dec 2026 10:38:42 +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=Iy7k+NXR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34DD51F000C2; Fri, 4 Dec 2026 10:38:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380722; bh=FPMUi4fT8Mm034JGqMn+jXYwkzY2cATW01TIqXSQUks=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Iy7k+NXR/sa2pLWLzbVHUVsDlUYdR4WpeLAX00E40cqJ61CeR9YKBXMar8I5E0BWk SlJbGy8BNd+WwgnQ9HToJ/+NdMUTclUUTPk6qctf3xARbUiwjcTait3VgBg5eVAQuu wgBUD2iK6l3qw74owhx9kkVUE6/gLRqur4coVe8c= 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 7.3 394/742] drm/amdkfd: check CRIU SVM priv data bounds before allocating Date: Fri, 4 Dec 2026 19:04:18 +0900 Message-ID: <20261204100645.560767111@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-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 @@ -4213,15 +4213,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);