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 52C701FDD for ; Tue, 21 May 2024 15:25:55 +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=1716305155; cv=none; b=WpdIsMLF9lOylcdVvyahet/hgdEphw3v6SDKsiTc32x0SJdFvVQCajUeCwah5c1P3ceOpawZY10urNC65LAS9FGrdhWu2nfq3tmE7Wj1nGPi0138s/aanAjWlyLIV+niMQs9iNH+Uhe3AARAQXDonnzo9533fZDSYqLqhtNykrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716305155; c=relaxed/simple; bh=1687k+MI4w8Sk4lOL17NMWEilzZUUe/0v85eJCg6HHY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aLr/UhO+xsGAN/QL0VbtElze2yMwhWz4KlZK8c4Tr1wQxOyvk48ap93MTX6NrpRtutHagTBkeIbOu83hoLBTxMl0H9CCHT92a1+K4HWY6O+2TOIEWe2lUeBgStl4ZtU814muiXPiI6GplPW+6bqWiwKmdc9J4e5yslAXcfaYR+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jfqDJ9RC; 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="jfqDJ9RC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9DBFC4AF08; Tue, 21 May 2024 15:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716305155; bh=1687k+MI4w8Sk4lOL17NMWEilzZUUe/0v85eJCg6HHY=; h=From:To:Cc:Subject:Date:Reply-to:From; b=jfqDJ9RCdTUYPo9J5enMODX7WWNitZoN1RFjnNfHOCCWh/t/rxG9wKVwiZ4GKHffD 84sd2Wa2o/OuO/cPzTfAlcZuw3ghn/vgWVoxMLbZgjFItf/XyLDosVxp7+0no/RVpf W/9qvUSxYfiF5wMSPfBQc/n9FEI4JmpKXbJdy39Q= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-52738: drm/amdgpu/fence: Fix oops due to non-matching drm_sched init/fini Date: Tue, 21 May 2024 17:23:15 +0200 Message-ID: <2024052101-CVE-2023-52738-f1bb@gregkh> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3652; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=1687k+MI4w8Sk4lOL17NMWEilzZUUe/0v85eJCg6HHY=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk+e0In3RNl6TLtles8V1Iy/9qTJTVhe16plye/XykT4 CLoLNfXEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABeJZpgra9oj3rq7hEddurLz WOpNWSsuuQ0Ms9mXhZ+aZdhvG7CFjdF4g8Jd45llawE= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: drm/amdgpu/fence: Fix oops due to non-matching drm_sched init/fini Currently amdgpu calls drm_sched_fini() from the fence driver sw fini routine - such function is expected to be called only after the respective init function - drm_sched_init() - was executed successfully. Happens that we faced a driver probe failure in the Steam Deck recently, and the function drm_sched_fini() was called even without its counter-part had been previously called, causing the following oops: amdgpu: probe of 0000:04:00.0 failed with error -110 BUG: kernel NULL pointer dereference, address: 0000000000000090 PGD 0 P4D 0 Oops: 0002 [#1] PREEMPT SMP NOPTI CPU: 0 PID: 609 Comm: systemd-udevd Not tainted 6.2.0-rc3-gpiccoli #338 Hardware name: Valve Jupiter/Jupiter, BIOS F7A0113 11/04/2022 RIP: 0010:drm_sched_fini+0x84/0xa0 [gpu_sched] [...] Call Trace: amdgpu_fence_driver_sw_fini+0xc8/0xd0 [amdgpu] amdgpu_device_fini_sw+0x2b/0x3b0 [amdgpu] amdgpu_driver_release_kms+0x16/0x30 [amdgpu] devm_drm_dev_init_release+0x49/0x70 [...] To prevent that, check if the drm_sched was properly initialized for a given ring before calling its fini counter-part. Notice ideally we'd use sched.ready for that; such field is set as the latest thing on drm_sched_init(). But amdgpu seems to "override" the meaning of such field - in the above oops for example, it was a GFX ring causing the crash, and the sched.ready field was set to true in the ring init routine, regardless of the state of the DRM scheduler. Hence, we ended-up using sched.ops as per Christian's suggestion [0], and also removed the no_scheduler check [1]. [0] https://lore.kernel.org/amd-gfx/984ee981-2906-0eaf-ccec-9f80975cb136@amd.com/ [1] https://lore.kernel.org/amd-gfx/cd0e2994-f85f-d837-609f-7056d5fb7231@amd.com/ The Linux kernel CVE team has assigned CVE-2023-52738 to this issue. Affected and fixed versions =========================== Issue introduced in 5.15 with commit 067f44c8b459 and fixed in 5.15.94 with commit 2e557c8ca2c5 Issue introduced in 5.15 with commit 067f44c8b459 and fixed in 6.1.12 with commit 2bcbbef9cace Issue introduced in 5.15 with commit 067f44c8b459 and fixed in 6.2 with commit 5ad7bbf3dba5 Issue introduced in 5.14.10 with commit 8ba968ae672b Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2023-52738 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/2e557c8ca2c585bdef591b8503ba83b85f5d0afd https://git.kernel.org/stable/c/2bcbbef9cace772f5b7128b11401c515982de34b https://git.kernel.org/stable/c/5ad7bbf3dba5c4a684338df1f285080f2588b535