Skip to content

Conversation

pvts-mat
Copy link
Contributor

@pvts-mat pvts-mat commented Apr 11, 2025

[LTS 9.2]
CVE-2023-5633
VULN-8161

Problem

https://www.cve.org/CVERecord?id=CVE-2023-5633

The reference count changes made as part of the CVE-2023-33951 and CVE-2023-33952 fixes exposed a use-after-free flaw in the way memory objects were handled when they were being used to store a surface. When running inside a VMware guest with 3D acceleration enabled, a local, unprivileged user could potentially use this flaw to escalate their privileges.

Analysis and solution

Official fix

Following https://bugzilla.redhat.com/show_bug.cgi?id=2245663

Upstream patch & commit:
https://lists.freedesktop.org/archives/dri-devel/2023-September/424805.html
torvalds/linux@91398b4

the official solution for mainline kernel is contained in the 91398b4 commit.

Applicability analysis

The buggy commit 9ef8d83 being the source of CVE-2023-5633, fixed by 91398b4, was itself a fix of a buggy commit 8afa13a with associated additional CVE-2023-33951 and CVE-2023-33952. The following table summarizes the relations between all commits involved in the problem, hopefully clarifying the issue

Commit Linux Semantics Fix for CVE Comments
8afa13a 5.17 Issue chain init - -
9ef8d83 6.4 Original fix of 8afa13a CVE-2023-33951, CVE-2023-33952 Identified as fix for CVE-2023-33951 in ZDI-CAN-20110, as fix for CVE-2023-33952 in ZDI-CAN-20292
a950b98 6.2 Backport of 9ef8d83 CVE-2023-33951, CVE-2023-33952 Formally not a backport, but "(cherry picked from commit 9ef8d83)" in the commit msg, so de facto a backport
0a127ac 6.1 Backport of 9ef8d83 CVE-2023-33951, CVE-2023-33952 Formally a backport of a950b98 (commit msg "commit a950b98 upstream."), but the original for a950b98 is 9ef8d83
91398b4 6.6 Original fix of a950b98 CVE-2023-5633 Identified as the fix for CVE-2023-5633 in Bugzilla 2245663
1474b39 6.5 Backport of 91398b4 CVE-2023-5633 Formal backport ("commit 91398b4 upstream." in commit msg)
104f956 6.1 Backport of 91398b4 CVE-2023-5633 Formal backport ("commit 91398b4 upstream." in commit msg)

The files associated with each of these commits, as would be listed by

git --no-pager log --pretty= --name-only -n 1 ‹hash›

can be gathered in the following table, defining the changes domain.

  8afa13a 9ef8d83 91398b4 104f956
    a950b98 1474b39  
    0a127ac    
drivers/gpu/drm/vmwgfx/Kconfig yes no no no
drivers/gpu/drm/vmwgfx/Makefile yes no no no
drivers/gpu/drm/vmwgfx/ttm_object.c yes no no no
drivers/gpu/drm/vmwgfx/ttm_object.h yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h no no yes no
drivers/gpu/drm/vmwgfx/vmwgfx_context.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c yes no yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h yes no yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_prime.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c yes no yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c yes yes yes yes
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c yes no no no
drivers/gpu/drm/vmwgfx/vmwgfx_va.c yes no no no

The recent history of the changes to these files is

git --no-pager log --decorate  --format="%h %cd %d %s" --date=short -n 11 ciqlts9_2 -- \
    drivers/gpu/drm/vmwgfx/Kconfig \
    drivers/gpu/drm/vmwgfx/Makefile \
    drivers/gpu/drm/vmwgfx/ttm_object.c \
    drivers/gpu/drm/vmwgfx/ttm_object.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_bo.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_bo.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_context.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_drv.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_drv.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_fb.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_fence.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_gem.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_kms.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_kms.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_prime.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_resource.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_shader.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_surface.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_va.c

7da1f53fe 2023-01-20  drm/vmwgfx: Validate the box size for the snooped cursor
55d637fd8 2023-01-20  drm/vmwgfx: Don't use screen objects when SEV is active
7a3deb5bc 2022-12-01  Merge DRM changes from upstream v5.19..v6.0
378bf4751 2022-12-01  Merge DRM changes from upstream v5.18..v5.19
959db9309 2022-10-25  fbdev: Track deferred-I/O pages in pageref struct
753ba0c52 2022-07-25  drm/vmwgfx: Fix an invalid read
a7ef314e5 2022-07-25  drm/vmwgfx: validate the screen formats
99fc716fc 2022-05-31  Merge DRM changes from upstream v5.17..v5.18
105d2d483 2022-05-31  Merge DRM changes from upstream v5.16..v5.17
75030c7ea 2022-05-31  Merge DRM changes from upstream v5.15..v5.16
495a018a8 2022-05-31  Merge DRM changes from upstream v5.14..v5.15

Consider the history of the same files in the ciqlts9_4 version

git --no-pager log --decorate  --format="%h %cd %d %s" --date=short -n 23 ciqlts9_4 -- \
    drivers/gpu/drm/vmwgfx/Kconfig \
    drivers/gpu/drm/vmwgfx/Makefile \
    drivers/gpu/drm/vmwgfx/ttm_object.c \
    drivers/gpu/drm/vmwgfx/ttm_object.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_bo.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_bo.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_context.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_drv.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_drv.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_fb.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_fence.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_gem.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_kms.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_kms.h \
    drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_prime.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_resource.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_shader.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_surface.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c \
    drivers/gpu/drm/vmwgfx/vmwgfx_va.c

7dccc9633 2024-02-15  Merge: DRM Stable Backport 9.4 from v6.6.15
8186e461f 2024-02-02  drm/vmwgfx: Fix possible null pointer derefence with invalid contexts
9d79a103e 2024-02-01  drm: Disable the cursor plane on atomic contexts with virtualized drivers
a0b1e6061 2024-02-01  drm: Update file owner during use
b8df8e7b4 2023-12-09  Merge DRM changes from upstream v6.5..v6.6
26418f1a3 2023-12-09  Merge DRM changes from upstream v6.4..v6.5
22ac03e5c 2023-12-09  Merge DRM changes from upstream v6.3..v6.4
60c359319 2023-06-19  drm/vmwgfx: Fix Legacy Display Unit atomic drm support
9cfbbaba6 2023-06-19  Partial revert of "mm: replace vma->vm_flags direct modifications with modifier calls"
eaba25cc8 2023-06-19  Merge DRM changes from upstream v6.2..v6.3
6d713afb6 2023-06-19  Merge DRM changes from upstream v6.1..v6.2
4cb818386 2023-06-16  Merge DRM changes from upstream v6.0.8..v6.1
7da1f53fe 2023-01-20  drm/vmwgfx: Validate the box size for the snooped cursor
55d637fd8 2023-01-20  drm/vmwgfx: Don't use screen objects when SEV is active
7a3deb5bc 2022-12-01  Merge DRM changes from upstream v5.19..v6.0
378bf4751 2022-12-01  Merge DRM changes from upstream v5.18..v5.19
959db9309 2022-10-25  fbdev: Track deferred-I/O pages in pageref struct
753ba0c52 2022-07-25  drm/vmwgfx: Fix an invalid read
a7ef314e5 2022-07-25  drm/vmwgfx: validate the screen formats
99fc716fc 2022-05-31  Merge DRM changes from upstream v5.17..v5.18
105d2d483 2022-05-31  Merge DRM changes from upstream v5.16..v5.17
75030c7ea 2022-05-31  Merge DRM changes from upstream v5.15..v5.16
495a018a8 2022-05-31  Merge DRM changes from upstream v5.14..v5.15

The chronology of ciqlts9_4 fully contains that of ciqlts9_2, at the same time containing all three of the commits in the problem chain (or their backport equivalents):

                                                            _
7dccc9633  Merge: DRM Stable Backport 9.4 from v6.6.15      |9.4
8186e461f  drm/vmwgfx: Fix possible null pointer derefenc   |
9d79a103e  drm: Disable the cursor plane on atomic contex   |
a0b1e6061  drm: Update file owner during use                |
b8df8e7b4  Merge DRM changes from upstream v6.5..v6.6       |     <-- CVE-2023-5633 fix commit 91398b41
26418f1a3  Merge DRM changes from upstream v6.4..v6.5       |         contained in the merge bulk
22ac03e5c  Merge DRM changes from upstream v6.3..v6.4       |
60c359319  drm/vmwgfx: Fix Legacy Display Unit atomic drm   |
9cfbbaba6  Partial revert of "mm: replace vma->vm_flags d   |
eaba25cc8  Merge DRM changes from upstream v6.2..v6.3       |
6d713afb6  Merge DRM changes from upstream v6.1..v6.2       |     <-- CVE-2023-33951 & CVE-2023-33952
4cb818386  Merge DRM changes from upstream v6.0.8..v6.1     |  _      fix commit a950b989
7da1f53fe  drm/vmwgfx: Validate the box size for the snoo   |  |9.2   contained in the merge bulk
55d637fd8  drm/vmwgfx: Don't use screen objects when SEV    |  |
7a3deb5bc  Merge DRM changes from upstream v5.19..v6.0      |  |
378bf4751  Merge DRM changes from upstream v5.18..v5.19     |  |
959db9309  fbdev: Track deferred-I/O pages in pageref str   |  |
753ba0c52  drm/vmwgfx: Fix an invalid read                  |  |
a7ef314e5  drm/vmwgfx: validate the screen formats          |  |
99fc716fc  Merge DRM changes from upstream v5.17..v5.18     |  |
105d2d483  Merge DRM changes from upstream v5.16..v5.17     |  |  <-- Issues chain init commit 8afa13a0
75030c7ea  Merge DRM changes from upstream v5.15..v5.16     |  |      contained in the merge bulk
495a018a8  Merge DRM changes from upstream v5.14..v5.15     |  |

Summary and discussion

The fix for CVE-2023-5633 is contained in the commit which is not even present in the Rocky version 9.2. This may or may not mean that the vulnerability doesn't apply.

  • The mainline fix commit's classification as fixing a950b98 suggest the bug was introduced by a commit missing from 9.2 history, therefore not applicable.
  • The wording "The reference count changes made as part of [commit a950b98 changes] exposed a use-after-free flaw" in https://bugzilla.redhat.com/show_bug.cgi?id=2245663 comment suggests the bug was there before the a950b98 commit, possibly on the 9.2 version's timeline, therefore the CVE is applicable.

At the same time the investigation found CVE-2023-33951 and CVE-2023-33952 which definitely are applicable to Rocky 9.2, and the potential fix for CVE-2023-5633 would have to include the fix for them anyway, suggesting the broadening of scope for the vulnerability remedition. On the other hand the amount of changes is high and the commits don't seem to isolate specific problems well, risking the broadening of scope even further, to the point of equalizing the drivers/gpu/drm/vmwgfx driver's version with that contained in Rocky 9.4. The difficulty of testing changes in this driver should also be considered.

@pvts-mat pvts-mat mentioned this pull request Apr 14, 2025
github-actions bot pushed a commit that referenced this pull request Sep 7, 2025
JIRA: https://issues.redhat.com/browse/RHEL-102691

commit 0370fb1
Author: Sudeep Holla <[email protected]>
Date: Thu, 18 Apr 2024 11:29:32 +0100

    If the firmware returns incorrect SRI/NRI number, we fail to set it up
    in the kernel which is absolutely fine.

    However, we don't reset the stashed value of sched_recv or notif_pend
    IRQs. When we call ffa_notifications_cleanup() in case of failures to
    setup the notifications, we end up calling free_percpu_irq() from
    ffa_uninit_pcpu_irq() which results in the following warning:

      |  genirq: Flags mismatch irq 6. 00004401 (ARM-FFA-NPI) vs. 00004400 (IPI)
      |  ARM FF-A: Error registering percpu NPI nIRQ 6 : -16
      |  ARM FF-A: Notification setup failed -16, not enabled
      |  ------------[ cut here ]------------
      |  Trying to free already-free IRQ 6
      |  WARNING: CPU: 2 PID: 1 at kernel/irq/manage.c:2476 __free_percpu_irq+0x6c/0x138
      |  Modules linked in:
      |  CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.9.0-rc3 #211
      |  Hardware name: FVP Base RevC (DT)
      |  pstate: 614000c9 (nZCv daIF +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
      |  pc : __free_percpu_irq+0x6c/0x138
      |  lr : __free_percpu_irq+0x6c/0x138
      |  Call trace:
      |   __free_percpu_irq+0x6c/0x138
      |   free_percpu_irq+0x48/0x84
      |   ffa_notifications_cleanup+0x78/0x164
      |   ffa_notifications_setup+0x368/0x3c0
      |   ffa_init+0x2b4/0x36c
      |   do_one_initcall+0xe0/0x258
      |   do_initcall_level+0x8c/0xac
      |   do_initcalls+0x54/0x94
      |   do_basic_setup+0x1c/0x28
      |   kernel_init_freeable+0x108/0x174
      |   kernel_init+0x20/0x1a4
      |   ret_from_fork+0x10/0x20

    Fix the same by resetting the stashed copy of IRQ values to 0 in case
    of any failure to set them up properly.

    Cc: Jens Wiklander <[email protected]>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sudeep Holla <[email protected]>

Signed-off-by: Marcin Juszkiewicz <[email protected]>
github-actions bot pushed a commit that referenced this pull request Oct 12, 2025
The way tracing_mark_raw_write() records its data is that it has the
following structure:

  struct {
	struct trace_entry;
	int id;
	char buf[];
  };

But memcpy(&entry->id, buf, size) triggers the following warning when the
size is greater than the id:

 ------------[ cut here ]------------
 memcpy: detected field-spanning write (size 6) of single field "&entry->id" at kernel/trace/trace.c:7458 (size 4)
 WARNING: CPU: 7 PID: 995 at kernel/trace/trace.c:7458 write_raw_marker_to_buffer.isra.0+0x1f9/0x2e0
 Modules linked in:
 CPU: 7 UID: 0 PID: 995 Comm: bash Not tainted 6.17.0-test-00007-g60b82183e78a-dirty #211 PREEMPT(voluntary)
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
 RIP: 0010:write_raw_marker_to_buffer.isra.0+0x1f9/0x2e0
 Code: 04 00 75 a7 b9 04 00 00 00 48 89 de 48 89 04 24 48 c7 c2 e0 b1 d1 b2 48 c7 c7 40 b2 d1 b2 c6 05 2d 88 6a 04 01 e8 f7 e8 bd ff <0f> 0b 48 8b 04 24 e9 76 ff ff ff 49 8d 7c 24 04 49 8d 5c 24 08 48
 RSP: 0018:ffff888104c3fc78 EFLAGS: 00010292
 RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000000000
 RDX: 0000000000000000 RSI: 1ffffffff6b363b4 RDI: 0000000000000001
 RBP: ffff888100058a00 R08: ffffffffb041d459 R09: ffffed1020987f40
 R10: 0000000000000007 R11: 0000000000000001 R12: ffff888100bb9010
 R13: 0000000000000000 R14: 00000000000003e3 R15: ffff888134800000
 FS:  00007fa61d286740(0000) GS:ffff888286cad000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000560d28d509f1 CR3: 00000001047a4006 CR4: 0000000000172ef0
 Call Trace:
  <TASK>
  tracing_mark_raw_write+0x1fe/0x290
  ? __pfx_tracing_mark_raw_write+0x10/0x10
  ? security_file_permission+0x50/0xf0
  ? rw_verify_area+0x6f/0x4b0
  vfs_write+0x1d8/0xdd0
  ? __pfx_vfs_write+0x10/0x10
  ? __pfx_css_rstat_updated+0x10/0x10
  ? count_memcg_events+0xd9/0x410
  ? fdget_pos+0x53/0x5e0
  ksys_write+0x182/0x200
  ? __pfx_ksys_write+0x10/0x10
  ? do_user_addr_fault+0x4af/0xa30
  do_syscall_64+0x63/0x350
  entry_SYSCALL_64_after_hwframe+0x76/0x7e
 RIP: 0033:0x7fa61d318687
 Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
 RSP: 002b:00007ffd87fe0120 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
 RAX: ffffffffffffffda RBX: 00007fa61d286740 RCX: 00007fa61d318687
 RDX: 0000000000000006 RSI: 0000560d28d509f0 RDI: 0000000000000001
 RBP: 0000560d28d509f0 R08: 0000000000000000 R09: 0000000000000000
 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000006
 R13: 00007fa61d4715c0 R14: 00007fa61d46ee80 R15: 0000000000000000
  </TASK>
 ---[ end trace 0000000000000000 ]---

This is because fortify string sees that the size of entry->id is only 4
bytes, but it is writing more than that. But this is OK as the
dynamic_array is allocated to handle that copy.

The size allocated on the ring buffer was actually a bit too big:

  size = sizeof(*entry) + cnt;

But cnt includes the 'id' and the buffer data, so adding cnt to the size
of *entry actually allocates too much on the ring buffer.

Change the allocation to:

  size = struct_size(entry, buf, cnt - sizeof(entry->id));

and the memcpy() to unsafe_memcpy() with an added justification.

Cc: [email protected]
Cc: Masami Hiramatsu <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Andrew Morton <[email protected]>
Link: https://lore.kernel.org/[email protected]
Fixes: 64cf7d0 ("tracing: Have trace_marker use per-cpu data to read user space")
Reported-by: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Steven Rostedt (Google) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant