mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 02:20:15 +01:00
read-only mirror of https://gitlab.freedesktop.org/mesa/drm
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> |
||
|---|---|---|
| amdgpu | ||
| android | ||
| data | ||
| etnaviv | ||
| exynos | ||
| freedreno | ||
| include/drm | ||
| intel | ||
| man | ||
| nouveau | ||
| omap | ||
| radeon | ||
| tegra | ||
| tests | ||
| vc4 | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| Android.bp | ||
| Android.sources.bp | ||
| Android.sources.bp.mk | ||
| CleanSpec.mk | ||
| CONTRIBUTING.rst | ||
| core-symbols.txt | ||
| gen_table_fourcc.py | ||
| libdrm.pc.in | ||
| libdrm_lists.h | ||
| libdrm_macros.h | ||
| libsync.h | ||
| meson.build | ||
| meson_options.txt | ||
| README.rst | ||
| RELEASING | ||
| symbols-check.py | ||
| util_double_list.h | ||
| util_math.h | ||
| xf86atomic.h | ||
| xf86drm.c | ||
| xf86drm.h | ||
| xf86drmHash.c | ||
| xf86drmHash.h | ||
| xf86drmMode.c | ||
| xf86drmMode.h | ||
| xf86drmRandom.c | ||
| xf86drmRandom.h | ||
| xf86drmSL.c | ||
libdrm - userspace library for drm
----------------------------------
This is libdrm, a userspace library for accessing the DRM, direct rendering
manager, on Linux, BSD and other operating systems that support the ioctl
interface.
The library provides wrapper functions for the ioctls to avoid exposing the
kernel interface directly, and for chipsets with drm memory manager, support
for tracking relocations and buffers.
New functionality in the kernel DRM drivers typically requires a new libdrm,
but a new libdrm will always work with an older kernel.
libdrm is a low-level library, typically used by graphics drivers such as
the Mesa drivers, the X drivers, libva and similar projects.
Syncing with the Linux kernel headers
-------------------------------------
The library should be regularly updated to match the recent changes in the
`include/uapi/drm/`.
libdrm maintains a human-readable version for the token format modifier, with
the simpler ones being extracted automatically from `drm_fourcc.h` header file
with the help of a python script. This might not always possible, as some of
the vendors require decoding/extracting them programmatically. For that
reason one can enhance the current vendor functions to include/provide the
newly added token formats, or, in case there's no such decoding
function, to add one that performs the tasks of extracting them.
For simpler format modifier tokens there's a script (gen_table_fourcc.py) that
creates a static table, by going over `drm_fourcc.h` header file. The script
could be further modified if it can't handle new (simpler) token format
modifiers instead of the generated static table.
Compiling
---------
To set up meson:
meson builddir/
By default this will install into /usr/local, you can change your prefix
with --prefix=/usr (or `meson configure builddir/ -Dprefix=/usr` after
the initial meson setup).
Then use ninja to build and install:
ninja -C builddir/ install
If you are installing into a system location you will need to run install
separately, and as root.