mesa-drm/amdgpu
Jesse.Zhang 7518cc4fdd amdgpu: Add parameter validation to amdgpu_bo functions to fix SIGSEGV
This commit adds essential parameter validation to several key
functions in amdgpu_bo.c to prevent null pointer dereferences
that were causing segmentation faults and improve overall code
robustness.

The changes address the following crash scenario:
Received signal SIGSEGV.
Stack trace:
 #0 [fatal_sig_handler+0x17b]
 #1 [__sigaction+0x50]
 #2 [amdgpu_bo_alloc+0x37]
 #3 [__igt_unique____real_main461+0x7d5]
 #4 [main+0x2d]
 #5 [__libc_init_first+0x90]
 #6 [__libc_start_main+0x80]
 #7 [_start+0x25]

Changes made:

1. amdgpu_bo_alloc():
   - Validate alloc_buffer and buf_handle parameters
   - Return -EINVAL if either is NULL
   - Prevents null pointer dereference in memset and subsequent operations

2. amdgpu_bo_set_metadata():
   - Validate info parameter
   - Return -EINVAL if info is NULL
   - Prevents accessing invalid metadata structure

3. amdgpu_bo_query_info():
   - Validate info parameter in addition to existing bo->handle check
   - Return -EINVAL if info is NULL
   - Prevents writing to invalid info pointer

4. amdgpu_bo_list_create():
   - Validate resources parameter
   - Return -EINVAL if resources is NULL when number_of_resources > 0
   - Prevents invalid memory access during resource array processing

These changes ensure proper error handling when callers pass invalid
null pointers, preventing potential segmentation faults and making
the API more robust against programming errors. The validation occurs
early in each function to minimize performance impact.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
2025-10-22 08:59:55 +08:00
..
.editorconfig Add meson build system 2018-01-12 09:40:48 -08:00
amdgpu-symbols.txt amdgpu: Add amdgpu userqueue IOCTL functions 2025-04-10 10:03:07 -04:00
amdgpu.h amdgpu: Add queue priority and secure flags support for user queues 2025-04-14 15:37:51 +08:00
amdgpu_asic_id.c amdgpu: Read model name from /proc/cpuinfo for APUs 2025-10-15 09:20:59 -05:00
amdgpu_bo.c amdgpu: Add parameter validation to amdgpu_bo functions to fix SIGSEGV 2025-10-22 08:59:55 +08:00
amdgpu_cs.c amdgpu: Make amdgpu_cs_signal_semaphore() thread-safe 2024-05-23 18:57:18 +00:00
amdgpu_device.c amdgpu: fix deinit logic 2024-03-27 08:55:26 +01:00
amdgpu_gpu_info.c drm/amdgpu: add new AMDGPU_INFO subquery for userqueue metadata 2025-04-10 13:20:00 +00:00
amdgpu_internal.h amdgpu: add amdgpu_va_manager 2024-03-21 10:56:29 +01:00
amdgpu_userq.c amdgpu: Add queue priority and secure flags support for user queues 2025-04-14 15:37:51 +08:00
amdgpu_vamgr.c amdgpu: add amdgpu_va_range_alloc2 2024-03-21 10:57:04 +01:00
amdgpu_vm.c amdgpu: annotate public functions 2018-09-19 22:46:45 -07:00
Android.bp Convert to Android.bp 2024-07-29 14:47:30 -04:00
Android.sources.bp Convert to Android.bp 2024-07-29 14:47:30 -04:00
handle_table.c amdgpu: fix off by one in handle_table_insert 2018-08-16 08:50:04 +02:00
handle_table.h amdgpu: add handle table implementation v2 2018-08-07 13:27:16 +02:00
libdrm_amdgpu.pc.in amdgpu: add libdrm as private requirement/dependency 2016-02-04 13:22:50 +00:00
meson.build meson: Do not check for meson version >=0.54 2025-05-20 11:05:27 +02:00