mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
intel: Fix stack overflow in intel_dump_gpu
Previously, the call to ensure_device_info in the intercepted ioctl would eventually result in another call to ioctl, recursing until stack overflow: - ioctl (intercepted) - ensure_device_info - intel_get_device_info_from_fd - intel_device_info_i915_get_info_from_fd - getparam - intel_ioctl - ioctl (intercepted) Signed-off-by: Benjamin Lee <benjamin@computer.surgery> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23418>
This commit is contained in:
parent
bd88c75d4c
commit
7e9b06f1c6
1 changed files with 28 additions and 2 deletions
|
|
@ -43,6 +43,7 @@
|
|||
#include "intel_aub.h"
|
||||
#include "aub_write.h"
|
||||
|
||||
#include "c11/threads.h"
|
||||
#include "dev/intel_debug.h"
|
||||
#include "dev/intel_device_info.h"
|
||||
#include "common/intel_gem.h"
|
||||
|
|
@ -488,8 +489,8 @@ maybe_init(int fd)
|
|||
output_filename, device, devinfo.ver);
|
||||
}
|
||||
|
||||
__attribute__ ((visibility ("default"))) int
|
||||
ioctl(int fd, unsigned long request, ...)
|
||||
static int
|
||||
intercept_ioctl(int fd, unsigned long request, ...)
|
||||
{
|
||||
va_list args;
|
||||
void *argp;
|
||||
|
|
@ -734,6 +735,31 @@ ioctl(int fd, unsigned long request, ...)
|
|||
}
|
||||
}
|
||||
|
||||
__attribute__ ((visibility ("default"))) int
|
||||
ioctl(int fd, unsigned long request, ...)
|
||||
{
|
||||
static thread_local bool entered = false;
|
||||
va_list args;
|
||||
void *argp;
|
||||
int ret;
|
||||
|
||||
va_start(args, request);
|
||||
argp = va_arg(args, void *);
|
||||
va_end(args);
|
||||
|
||||
/* Some of the functions called by intercept_ioctl call ioctls of their
|
||||
* own. These need to go to the libc ioctl instead of being passed back to
|
||||
* intercept_ioctl to avoid a stack overflow. */
|
||||
if (entered) {
|
||||
return libc_ioctl(fd, request, argp);
|
||||
} else {
|
||||
entered = true;
|
||||
ret = intercept_ioctl(fd, request, argp);
|
||||
entered = false;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue