From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 7219B37F8C1; Thu, 20 Aug 2026 15:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238964; cv=none; b=BFS+rFOVb4yTrqcAhxNaUxn5Roh3TKbbXLIbR8SR0FN5Xd6riDpmrb4h0o/0EtMgJXM1d/6f7sPYsRYuSzlHOCG9agkRB2ByFiapCqcqCTgJiRvLINQap2xvFgz7dzyBcZ3s6FTAIsCz82HZ/DlKnUWtMJhhHnZuC0rWzynYz+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238964; c=relaxed/simple; bh=Lccm6QjUdselXGcfkbi1ZUQvlLheYLfmG4Hsc0+3/U4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kPmd2NGmFylxAq0wUdpcSNoyTZeqHSXdS60ArHJGqB65LhTw9SgjMCPbnMFeoOFt/d7zAv8FsEz2EzS01fvw3+41uSjQiVMGcx9S820gAFxtUv5h7sfuMCYBr7w5XDsIdDiAWI1T14OjqZHosap1hGqSvaBmszaFXbqyac92xZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ahs3snYF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ahs3snYF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAEBE1F000E9; Thu, 20 Aug 2026 15:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787238963; bh=GQxcC2MtIHtaj2n0zIH4NXQIFE+FIfIIrx9WE6m7waI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ahs3snYF3I6jgvA7snqGsjXjVH3iUwoyuVJpJdtNAAJdh9LZ4iPqOGiKQYJXg782w SzMQgylA055AydNmfoTnD6bvy3KsaIW9nHFXmi5PphckPvbW79vZUQFyuuulTiVOgf oDLBPRfBlPt+EJcj7o0364bJ2Z5O92y+FZ6OilcU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , =?UTF-8?q?Christian=20K=C3=B6nig?= , Junrui Luo , Alex Deucher Subject: [PATCH 6.18 102/217] drm/amdgpu: disallow multiple FENCE chunks in one submit Date: Thu, 20 Aug 2026 16:54:30 +0200 Message-ID: <20260820145240.816315768@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145237.531699751@linuxfoundation.org> References: <20260820145237.531699751@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo commit 931cd1d1baeae68e8eb2c23bc1f3d8934dca6241 upstream. amdgpu_cs_pass1() dispatches on chunk_id once per chunk without rejecting repeated ids. p->uf_bo is a single-slot field, so a submission carrying two AMDGPU_CHUNK_ID_FENCE chunks runs amdgpu_cs_p1_user_fence() twice, and the second run overwrites p->uf_bo with a freshly referenced BO without dropping the reference taken by the first. amdgpu_cs_parser_fini() only unrefs the final p->uf_bo, so every FENCE chunk but the last leaks a BO reference. The leaked BO outlives handle close and process exit. Reject duplicate FENCE chunks the same way commit fec5f8e8c6bc ("drm/amdgpu: disallow multiple BO_HANDLES chunks in one submit") did for p->bo_list. Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)") Reported-by: Yuhao Jiang Assisted-by: Claude:claude-opus-5 Cc: stable@vger.kernel.org Reviewed-by: Christian König Signed-off-by: Junrui Luo Signed-off-by: Alex Deucher (cherry picked from commit 665b1fc2a1845206408f9a2c6da67101789edb82) Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -261,6 +261,10 @@ static int amdgpu_cs_pass1(struct amdgpu if (size < sizeof(struct drm_amdgpu_cs_chunk_fence)) goto free_partial_kdata; + /* Only a single user fence is allowed to simplify handling. */ + if (p->uf_bo) + goto free_partial_kdata; + ret = amdgpu_cs_p1_user_fence(p, p->chunks[i].kdata, &uf_offset); if (ret)