drm/amdkfd: Add bounds check for AMDKFD_IOC_WAIT_EVENTS
Subsystems (3)
PATCH 1/1 drm/amdkfd: Add bounds check for AMDKFD_IOC_WAIT_EVENTS
The kfd_wait_on_events ioctl passes a user-supplied num_events parameter directly to alloc_event_waiters() which calls kcalloc() without validation. This allows unprivileged users with /dev/kfd access to trigger large kernel memory allocations, potentially causing memory exhaustion and denial of service via the OOM killer.
Add a check to reject num_events values exceeding KFD_SIGNAL_EVENT_LIMIT (4096), which is the maximum number of events a single process can create.
--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +2 -1
@@ -799,7 +799,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events) {struct kfd_event_waiter *event_waiters;uint32_t i; - +if (num_events >KFD_SIGNAL_EVENT_LIMIT ) +return NULL ; event_waiters =kcalloc (num_events,sizeof (struct kfd_event_waiter ),GFP_KERNEL );if (!event_waiters)
Signature · 1 line
2.43.0
AMD General
ping
Quoted 42 lines
-----Original Message-----
From: Clement, Sunday <[email protected]>
Sent: Tuesday, May 19, 2026 10:18 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Clement, Sunday <[email protected]>
Subject: [PATCH] drm/amdkfd: Add bounds check forAMDKFD_IOC_WAIT_EVENTSThe
kfd_wait_on_eventsioctl passes a user-suppliednum_eventsparameter directly toalloc_event_waiters()which callskcalloc()without validation. This allows unprivileged users with/dev/kfdaccess to trigger large kernel memory allocations, potentially causing memory exhaustion and denial of service via the OOM killer.Add a check to reject
num_eventsvalues exceedingKFD_SIGNAL_EVENT_LIMIT(4096), which is the maximum number of events a single process can create.Signed-off-by Sunday Clement <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdkfd/kfd_events.c +2
-2@@ -799,7 +799,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events) {struct kfd_event_waiter *event_waiters;uint32_t i; - +if (num_events >KFD_SIGNAL_EVENT_LIMIT ) +return NULL ; event_waiters =kcalloc (num_events,sizeof (struct kfd_event_waiter ),GFP_KERNEL );if (!event_waiters) --2.43.0
AMD General
________________________________
From: Clement, Sunday <[email protected]>
Sent: Tuesday, May 19, 2026 10:18 AM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Kasiviswanathan, Harish <[email protected]>; Clement, Sunday <[email protected]>
Subject: [PATCH] drm/amdkfd: Add bounds check for AMDKFD_IOC_WAIT_EVENTS
The kfd_wait_on_events ioctl passes a user-supplied num_events parameter directly to alloc_event_waiters() which calls kcalloc() without validation. This allows unprivileged users with /dev/kfd access to trigger large kernel memory allocations, potentially causing memory exhaustion and denial of service via the OOM killer.
Add a check to reject num_events values exceeding KFD_SIGNAL_EVENT_LIMIT (4096), which is the maximum number of events a single process can create.
--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +2 -1
@@ -799,7 +799,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events) {struct kfd_event_waiter *event_waiters;uint32_t i; - +if (num_events >KFD_SIGNAL_EVENT_LIMIT ) +return NULL ; event_waiters =kcalloc (num_events,sizeof (struct kfd_event_waiter ),GFP_KERNEL );if (!event_waiters)
--
2.43.0