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 B173D3D9041; Wed, 8 Apr 2026 18:34:26 +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=1775673266; cv=none; b=nIOhezYMgGtjN3UTLnLj4/46+E2i8KYA7CdlrRymXMI+oB8VQ3EPU/NoM24pV9isRu7Sl/LZo8z1BY6iRAPSsEF0LR4GW7t1CgIC54/IirXICVqpD5HG5NMIMoyxDqp50MdiOqDe+TCjOaeaHnXxOX5clJCifpz1FarhtE8RQf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673266; c=relaxed/simple; bh=IfpuPuiiQuOKFbpx+F2sPahwY8rb7CyRGhrDNCHrEsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sX48RhyO4wTjg/PhvM8OXlGa7K2FLr8s6Q5pDmzgfcgY1sqe2UNm4jU2upX+F4tYsfhmb49iWybSak5qlI+WLIE5auFmnGUj6d0b7mfTihB3idCVP+6zYlTkQa0wZP+9Cn9ziqoheU/af7tBIDkV8u6Tx36dVuissiIDpk6/iVw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t8m5QZ2r; 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="t8m5QZ2r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A576C2BC87; Wed, 8 Apr 2026 18:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775673266; bh=IfpuPuiiQuOKFbpx+F2sPahwY8rb7CyRGhrDNCHrEsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t8m5QZ2r8SyY3ZM1ayZP1NAY5HUhrcE0KI1+GwE/rqecBYs4cUB58Ih2e8kxRykgp CWBjIxpViNQvknN4x3NFhaXpUBTEdWiW7e62qjPB8nlAmTpkEqJ+b7fV8TMEGJXYQo Y+/wCQlFt87kFuhcP/wAuQgjig3lqfByFV/aUA4M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Junrui Luo , Alex Deucher Subject: [PATCH 6.18 165/277] drm/amdgpu: validate doorbell_offset in user queue creation Date: Wed, 8 Apr 2026 20:02:30 +0200 Message-ID: <20260408175940.030903201@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.836769063@linuxfoundation.org> References: <20260408175933.836769063@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo commit a018d1819f158991b7308e4f74609c6c029b670c upstream. amdgpu_userq_get_doorbell_index() passes the user-provided doorbell_offset to amdgpu_doorbell_index_on_bar() without bounds checking. An arbitrarily large doorbell_offset can cause the calculated doorbell index to fall outside the allocated doorbell BO, potentially corrupting kernel doorbell space. Validate that doorbell_offset falls within the doorbell BO before computing the BAR index, using u64 arithmetic to prevent overflow. Fixes: f09c1e6077ab ("drm/amdgpu: generate doorbell index for userqueue") Reported-by: Yuhao Jiang Signed-off-by: Junrui Luo Signed-off-by: Alex Deucher (cherry picked from commit de1ef4ffd70e1d15f0bf584fd22b1f28cbd5e2ec) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c @@ -358,6 +358,13 @@ amdgpu_userq_get_doorbell_index(struct a goto unpin_bo; } + /* Validate doorbell_offset is within the doorbell BO */ + if ((u64)db_info->doorbell_offset * db_size + db_size > + amdgpu_bo_size(db_obj->obj)) { + r = -EINVAL; + goto unpin_bo; + } + index = amdgpu_doorbell_index_on_bar(uq_mgr->adev, db_obj->obj, db_info->doorbell_offset, db_size); drm_dbg_driver(adev_to_drm(uq_mgr->adev),