Skip to content

[rlc-10/6.12.0-211.32.1.el10_2] Multiple patches tested (5 commits)#1442

Open
ciq-kernel-automation[bot] wants to merge 5 commits into
rlc-10/6.12.0-211.32.1.el10_2from
{roxanan}_rlc-10/6.12.0-211.32.1.el10_2
Open

[rlc-10/6.12.0-211.32.1.el10_2] Multiple patches tested (5 commits)#1442
ciq-kernel-automation[bot] wants to merge 5 commits into
rlc-10/6.12.0-211.32.1.el10_2from
{roxanan}_rlc-10/6.12.0-211.32.1.el10_2

Conversation

@ciq-kernel-automation

Copy link
Copy Markdown

Summary

This PR has been automatically created after successful completion of all CI stages.

Commit Message(s)

drm: Do not allow userspace to trigger kernel warnings in drm_gem_change_handle_ioctl()

cve CVE-2026-23149
commit-author Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
commit 12f15d52d38ac53f7c70ea3d4b3d76afed04e064
drm: Set old handle to NULL before prime swap in change_handle

cve CVE-2026-46215
commit-author Francis, David <David.Francis@amd.com>
commit 5e28b7b94408897e41c63477aabc9e1db439bc8c
drm: Replace old pointer to new idr

cve CVE-2026-52966
commit-author Edward Adam Davis <eadavis@qq.com>
commit dc366607c41c45fd0ae6f3db090f31dd611b644a
drm/gem: fix race between change_handle and handle_delete

cve-bf CVE-2026-46215
commit-author Zhenghang Xiao <kipreyyy@gmail.com>
commit 7164d78559b0ff29931a366a840a9e5dd53d4b7c
drm/gem: Try to fix change_handle ioctl, attempt 4

cve CVE-2026-53145
commit-author Simona Vetter <simona.vetter@ffwll.ch>
commit 1a4f03d22fb655e5f192244fb2c87d8066fcfca2

Test Results

✅ Build Stage

Architecture Build Time Total Time
x86_64 41m 10s 42m 5s
aarch64 24m 6s 24m 47s

✅ Boot Verification

✅ Kernel Selftests

Architecture Passed Failed Compared Against Status
x86_64 656 115 rlc-10/6.12.0-211.32.1.el10_2 ⚠️ No baseline available
aarch64 376 59 rlc-10/6.12.0-211.32.1.el10_2 ⚠️ No baseline available

✅ LTP Results

Architecture Passed Failed Compared Against Status
x86_64 1480 80 rlc-10/6.12.0-211.32.1.el10_2 ⚠️ No baseline available
aarch64 1451 81 rlc-10/6.12.0-211.32.1.el10_2 ⚠️ No baseline available

🤖 This PR was automatically generated by GitHub Actions
Run ID: 29338907098

roxanan1996 and others added 5 commits July 14, 2026 15:59
…nge_handle_ioctl()

cve CVE-2026-23149
commit-author Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
commit 12f15d5

Since GEM bo handles are u32 in the uapi and the internal implementation
uses idr_alloc() which uses int ranges, passing a new handle larger than
INT_MAX trivially triggers a kernel warning:

idr_alloc():
...
	if (WARN_ON_ONCE(start < 0))
		return -EINVAL;
...

Fix it by rejecting new handles above INT_MAX and at the same time make
the end limit calculation more obvious by moving into int domain.

	Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
	Reported-by: Zhi Wang <wangzhi@stu.xidian.edu.cn>
Fixes: 5309672 ("drm: Add DRM prime interface to reassign GEM handle")
	Cc: David Francis <David.Francis@amd.com>
	Cc: Felix Kuehling <felix.kuehling@amd.com>
	Cc: Christian König <christian.koenig@amd.com>
	Cc: <stable@vger.kernel.org> # v6.18+
	Tested-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
	Reviewed-by: Christian König <christian.koenig@amd.com>
	Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net>
Link: https://lore.kernel.org/r/20260123141540.76540-1-tvrtko.ursulin@igalia.com
(cherry picked from commit 12f15d5)
	Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
cve CVE-2026-46215
commit-author Francis, David <David.Francis@amd.com>
commit 5e28b7b

There was a potential race condition in change_handle. The ioctl
briefly had a single object with two idr entries; a concurrent
gem_close could delete the object and remove one of the handles
while leaving the other one dangling, which could subsequently
be dereferenced for a use-after-free.

To fix this, do the same dance that gem_close itself does.
(f6cd7da drm: Release driver references to handle before making it available again)
First idr_replace the old handle to NULL. Later, if the prime
operations are successful, actually close it.

create_tail required a similar dance to avoid a similar problem.
(bd46cec drm/gem: Fix race in drm_gem_handle_create_tail())
It idr_allocs the new handle with NULL, then swaps in the correct
object later to avoid races. We don't need to do that here, since
the only operations that could race are drm_prime, and
change_handle holds the prime lock for the entire duration.

v2: cleanups of error paths

	Signed-off-by: David Francis <David.Francis@amd.com>
Co-authored-by: Dave Airlie <airlied@gmail.com>
	Reported-by: Puttimet Thammasaeng <pwn8official@gmail.com>
	Tested-by: Vitaly Prosyak <Vitaly.Prosyak@amd.com>
	Cc: Simona Vetter <simona@ffwll.ch>
	Cc: stable@vger.kernel.org
	Cc: Christian Koenig <Christian.Koenig@amd.com>
Fixes: 5309672 ("drm: Add DRM prime interface to reassign GEM handle")
	Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 5e28b7b)
	Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
cve CVE-2026-52966
commit-author Edward Adam Davis <eadavis@qq.com>
commit dc36660

Commit 5e28b7b introduced a logical error by failing to replace the
newly generated IDR pointer to old id's pointer at the correct location
within the "change handle" logic; this resulted in the issue reported by
syzbot [1].

Specifically, the new IDR object pointer is intended to replace the original
id's pointer during the normal execution flow.

Additionally, an unnecessary conditional check for the ret exit path has
been removed.

[1]
!RB_EMPTY_ROOT(&prime_fpriv->dmabufs)
WARNING: drivers/gpu/drm/drm_prime.c:224 at drm_prime_destroy_file_private+0x48/0x60 drivers/gpu/drm/drm_prime.c:224, CPU#0: syz.0.17/5833
Call Trace:
 drm_file_free.part.0+0x7e6/0xcc0 drivers/gpu/drm/drm_file.c:269
 drm_file_free drivers/gpu/drm/drm_file.c:237 [inline]
 drm_close_helper.isra.0+0x186/0x200 drivers/gpu/drm/drm_file.c:290
 drm_release+0x1ab/0x360 drivers/gpu/drm/drm_file.c:438

Fixes: 5e28b7b ("drm: Set old handle to NULL before prime swap in change_handle")
	Reported-by: syzbot+d7c9eed171647e421013@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d7c9eed171647e421013
	Cc: stable@vger.kernel.org
	Tested-by: syzbot+d7c9eed171647e421013@syzkaller.appspotmail.com
	Signed-off-by: Edward Adam Davis <eadavis@qq.com>
	Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/tencent_C267296443AAA4567771176886DFF364A305@qq.com
(cherry picked from commit dc36660)
	Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
cve-bf CVE-2026-46215
commit-author Zhenghang Xiao <kipreyyy@gmail.com>
commit 7164d78

drm_gem_change_handle_ioctl leaves the old handle live in the IDR
during the window between spin_unlock(table_lock) and the final
spin_lock(table_lock). A concurrent drm_gem_handle_delete on the old
handle succeeds in this window, decrements handle_count to 0, and frees
the GEM object while the new handle's IDR entry still references it.

NULL the old handle's IDR entry before dropping table_lock so that any
concurrent GEM_CLOSE on the old handle sees NULL and returns -EINVAL.
Restore the old entry on the prime-bookkeeping error path.

Fixes: 5e28b7b ("drm: Set old handle to NULL before prime swap in change_handle")
	Signed-off-by: Zhenghang Xiao <kipreyyy@gmail.com>
	Cc: stable@vger.kernel.org
	Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20260526085313.26791-1-kipreyyy@gmail.com
(cherry picked from commit 7164d78)
	Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
cve CVE-2026-53145
commit-author Simona Vetter <simona.vetter@ffwll.ch>
commit 1a4f03d

[airlied: just added some comments on how to reenable]
On-list because the cat is out of the bag and we're clearly not good
enough to figure this out in private. The story thus far:

5e28b7b ("drm: Set old handle to NULL before prime swap in
change_handle") tried to fix a race condition between the gem_close and
gem_change_handle ioctls, but got a few things wrong:

- There's a confusion with the local variable handle, which is actually
  the new handle, and so the two-stage trick was actually applied to the
  wrong idr slot. 7164d78 ("drm/gem: fix race between
  change_handle and handle_delete") tried to fix that by adding yet
  another code block, but forgot to add the error handling. Which meant
  we now have two paths, both kinda wrong.

- dc36660 ("drm: Replace old pointer to new idr") tried to apply
  another fix, but inconsistently, again because of the handle confusion
  - this would be the right fix (kinda, somewhat, it's a mess) if we'd
  do the two-stage approach for the new handle. Except that wasn't the
  intent of the original fix.

We also didn't have an igt merged for the original ioctl, which is a big
no-go. This was attempted to address off-list in the original bugfix,
and amd QA people claimed the bug was fixed now. Very clearly that's not
the case. Here's my attempt to sort this out:

- Rename the local variable to new_handle, the old aliasing with
  args->handle is just too dangerously confusing.

- Merge the gem obj lookup with the two-stage idr_replace so that we
  avoid getting ourselves confused there.

- This means we don't have a surplus temporary reference anymore, only
  an inherited from the idr. A concurrent gem_close on the new_handle
  could steal that. Fix that with the same two-stage approach
  create_tail uses. This is a bit overkill as documented in the comment,
  but I also don't trust my ability to understand this all correctly, so
  go with the established pattern we have from other ioctls instead for
  maximum paranoia.

- Adjust error paths. I've tried to make the error and success paths
  common, because they are identical except for which handle is removed
  and on which we call idr_replace to (re)install the object again. But
  that made things messier to read, so I've left it at the more verbose
  version, which unfortunately hides the symmetry in the entire code
  flow a bit.

- While at it, also replace the 7 space indent with 1 tab.

And finally, because I flat out don't trust my abilities here at all
anymore:

- Disable the ioctl until we have the igt situation and everything else
  sorted out on-list and with full consensus.

v2:

Sashiko noticed that I didn't handle the error path for idr_replace
correctly, it must be checked with IS_ERR_OR_NULL like in
gem_handle_delete. So yeah, definitely should just the existing paths
1:1 because this is endless amounts of tricky.

Also add the Fixes: line for the original ioctl, I forgot that too.

	Reported-by: DARKNAVY (@DarkNavyOrg) <vr@darknavy.com>
	Signed-off-by: Simona Vetter <simona.vetter@ffwll.ch>
Fixes: dc36660 ("drm: Replace old pointer to new idr")
	Cc: syzbot+d7c9eed171647e421013@syzkaller.appspotmail.com
	Cc: stable@vger.kernel.org
	Cc: Edward Adam Davis <eadavis@qq.com>
	Cc: Dave Airlie <airlied@redhat.com>
	Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
	Cc: Maxime Ripard <mripard@kernel.org>
	Cc: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 5e28b7b ("drm: Set old handle to NULL before prime swap in change_handle")
	Cc: David Francis <David.Francis@amd.com>
	Cc: Puttimet Thammasaeng <pwn8official@gmail.com>
	Cc: Christian Koenig <Christian.Koenig@amd.com>
Fixes: 7164d78 ("drm/gem: fix race between change_handle and handle_delete")
	Cc: Zhenghang Xiao <kipreyyy@gmail.com>
Fixes: 5e28b7b ("drm: Set old handle to NULL before prime swap in change_handle")
	Reviewed-by: David Francis <David.Francis@amd.com>
	Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20260604194437.1725314-1-simona.vetter@ffwll.ch
(cherry picked from commit 1a4f03d)
	Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
@ciq-kernel-automation ciq-kernel-automation Bot added the created-by-kernelci Tag PRs that were automatically created when a user branch was pushed to the repo (kernelCI) label Jul 14, 2026

@kerneltoast kerneltoast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@PlaidCat PlaidCat requested a review from a team July 15, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by-kernelci Tag PRs that were automatically created when a user branch was pushed to the repo (kernelCI)

Development

Successfully merging this pull request may close these issues.

3 participants