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=1796382264; b=1ca0eItWs+ImhCYjU5pZE/SOuOd7qB4Xp1xb+vulRSujdP227lJ8HRy9Kh4XvO29tvWg 1jM5RFP9oBSIz5R7Kn5zNdDnXOnc1EG859yn/REU/fNZoELbWqIIEJiaMTH9NKttHiSs8 mpnUrPoolLHODNq511LlvQc0/na4IuolIO29IYwnDar2Q5o3PVDU4oMgeg3FAlEpOzzaT GeRjl3X/StBEpT+QOFJDWM3R7qj23nrhBDR8uZ9xNwt4rar0ogGifmuZdg6E5XXsKNmg3 TnpeMx3Skon4/vqgbiCf9JeP5IlZiqq8zbtHbeHH7vq7ZggghFBAPzqtfmbQtBnSANg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382264; 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=aJ0hOTtp+JPyMudD/l/46sIhsrPEWlrK1ad6kSrVIgQ=; b=LJCL9kL4q26ULEOsIF5ldtavpWbdoy+ub27wkLoPE4gkxdzVtFlitBxe42P+n52jbVBQ +5/ZnaQbc7ZfYbgfLmd5x4sFygpvPbs8JWpE9QFHDI7UpYZY4Co7ap1ls+fW0VRpzYyKg o1EtKUPLXEqhnE1N0poJFA39UYYio0qTKjtCyk/M1kJwB0S+or2/AF1lNX8C75Enuz3ef fp/dG1vU3UZgnt6omUkXF+2XbvjwXILlQcyBkneLCHZoJFU+BiBeQfSpM0BFRIcaUP4v5 yKFnNmaHh6k6y6v66zsC+N27CfQxOlrkucWn6xRj2DjdxkfbJfzGp5Zff6epHQlh4iw== 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=qT1PBd71; 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 CC215606A322; Fri, 4 Dec 2026 11:04:24 +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=qT1PBd71 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 455F81F000CE; Fri, 4 Dec 2026 11:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382264; bh=aJ0hOTtp+JPyMudD/l/46sIhsrPEWlrK1ad6kSrVIgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qT1PBd71C62LBfK7AUPv11T32Hwq/rz9CJ+Tai1RTlUVkHvq5PRRCSI14gCdG8Bhi ZosIs5KIvKv1MhV8xj5iARqclp/KjOCNsE+qsEN7t0JYd2JaxwjrvoE3ZwoMOATHb0 4QIg3PR/YiDGeJoY+T2m5gp9T9xgfdzd5+u2564c= 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.18 362/703] drm/amdkfd: check CRIU SVM priv data bounds before allocating Date: Fri, 4 Dec 2026 19:04:21 +0900 Message-ID: <20261204100637.441483555@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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 6.18-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 @@ -4116,15 +4116,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);